Submission #1498967
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define rep(i,n) REP(i,0,n) #define REP(i,s,e) for(int i=(s); i<(int)(e); i++) #define repr(i, n) REPR(i, n, 0) #define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--) #define pb push_back #define all(r) r.begin(),r.end() #define rall(r) r.rbegin(),r.rend() #define fi first #define se second typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int INF = 1e9; const ll MOD = 1e9 + 7; double EPS = 1e-8; int main(){ int n; cin >> n; vi a(n); rep(i, n) cin >> a[i]; vi b; b.pb(a[0]); REP(i, 1, n) { if(b.back() != a[i]) b.pb(a[i]); } if(b.size() == 1) { cout << 1 << endl; return 0; } vi c; c.pb(b[0] < b[1]); int idx = 1; while(idx+1 < b.size()) { if((b[idx+1] > b[idx])^c.back()) { if(idx+2 >= b.size()) { c.pb(0); break; } c.pb(b[idx+2] > b[idx+1]); idx++; } idx++; } cout << c.size() << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Sorted Arrays |
User | T1610 |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 1051 Byte |
Status | AC |
Exec Time | 41 ms |
Memory | 1400 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
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 | 1020 KB |
subtask_1_02.txt | AC | 20 ms | 768 KB |
subtask_1_03.txt | AC | 13 ms | 640 KB |
subtask_1_04.txt | AC | 41 ms | 1400 KB |
subtask_1_05.txt | AC | 41 ms | 1276 KB |
subtask_1_06.txt | AC | 41 ms | 1400 KB |
subtask_1_07.txt | AC | 41 ms | 1400 KB |
subtask_1_08.txt | AC | 40 ms | 640 KB |
subtask_1_09.txt | AC | 41 ms | 1400 KB |
subtask_1_10.txt | AC | 1 ms | 256 KB |
subtask_1_11.txt | AC | 1 ms | 256 KB |