Submission #1353653


Source Code Expand

#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n; cin>>n;
    vi v(n);rep(i,n)cin>>v[i];
    vi dp(n,0);
    int cnt=1,flag = 3,ans;
    rep(i,n-1){
        if(v[i]<v[i+1]){
            if(!i||flag==3){flag=1;}
            if(flag!=1){cnt++;flag=3;continue;}
            flag=1;
        }else if(v[i]>v[i+1]){
            if(!i||flag==3){flag=0; }
            if(flag!=0){cnt++;flag=3; continue;}
            flag=0;
        }else continue;
    }
    cout<<cnt<<endl;
}

Submission Info

Submission Time
Task A - Sorted Arrays
User yebityon
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1579 Byte
Status AC
Exec Time 41 ms
Memory 1024 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 17
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
subtask_1_01.txt AC 25 ms 768 KB
subtask_1_02.txt AC 20 ms 640 KB
subtask_1_03.txt AC 13 ms 512 KB
subtask_1_04.txt AC 41 ms 1024 KB
subtask_1_05.txt AC 41 ms 1024 KB
subtask_1_06.txt AC 41 ms 1024 KB
subtask_1_07.txt AC 41 ms 1024 KB
subtask_1_08.txt AC 41 ms 1024 KB
subtask_1_09.txt AC 41 ms 1024 KB
subtask_1_10.txt AC 1 ms 256 KB
subtask_1_11.txt AC 1 ms 256 KB