Submission #1352701


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;
    vector<int>v(n);rep(i,n)cin>>v[i];
    vector<int>dp(n,0);
    int flag = 0;
    int cnt=1;
    rep(i,n-1){
        if(!i||flag==2){if(v[i]<v[i+1])flag=1;else if(v[i]!=v[i+1])flag=0;else flag=2;}
        if(flag==1){
            if(v[i]<v[i+1])continue;
            else{
                if(v[i]==v[i+1])flag=2;
                else{
                    flag=0;
                    i+=1;
                    if(i==n-1)cnt++;
                    cnt++;
                }
            }
        }else{
            if(v[i]>v[i+1])continue;
            if(v[i]==v[i+1])flag=2;
            else{
                flag=1;
                i+=1;
                if(i==n-1)cnt++;
                cnt++;
            }
        }
    }
    cout<<cnt<<endl;
}

Submission Info

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

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 3
AC × 11
WA × 6
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 WA 25 ms 768 KB
subtask_1_02.txt AC 20 ms 640 KB
subtask_1_03.txt WA 13 ms 512 KB
subtask_1_04.txt WA 41 ms 1024 KB
subtask_1_05.txt AC 41 ms 1024 KB
subtask_1_06.txt WA 41 ms 1024 KB
subtask_1_07.txt WA 41 ms 1024 KB
subtask_1_08.txt AC 41 ms 1024 KB
subtask_1_09.txt WA 41 ms 1024 KB
subtask_1_10.txt AC 1 ms 256 KB
subtask_1_11.txt AC 1 ms 256 KB