Submission #1369600
Source Code Expand
#include <bits/stdc++.h> #define fi first #define se second #define sc scanf #define pr printf #define pb push_back #define ll long long #define fin(s) freopen( s, "r", stdin ); #define fout(s) freopen( s, "w", stdout ); const long long N = 100100; const long long MX = sqrt(N); const long long H = 17; const long long MAGIC = 1000; const long long mod = 1e9 + 7; using namespace std; int n; int a[N]; bool f(int a, int b, int c) { return (a <= b && b <= c || a >= b && b >= c); } void solve() { int cnt = 0; cin >> n; for(int i = 1; i <= n; i++){ cin >> a[i]; } for(int i = 3; i <= n; i++){ if(!f(a[i - 2], a[i - 1], a[i])){ cnt++; i += 1; } } cout << cnt + 1 << endl; } bool mtest = false; int main() { //fin("input.txt"); //fout("output.txt"); //fin("landscape.in"); //fout("landscape.out"); ios_base::sync_with_stdio(0); int TE = 1; if(mtest) cin >> TE; while(TE--) solve(); return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Sorted Arrays |
User | EliteWantsYou |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1219 Byte |
Status | WA |
Exec Time | 12 ms |
Memory | 640 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | 8 ms | 512 KB |
subtask_1_02.txt | AC | 6 ms | 512 KB |
subtask_1_03.txt | AC | 4 ms | 384 KB |
subtask_1_04.txt | AC | 12 ms | 640 KB |
subtask_1_05.txt | AC | 11 ms | 640 KB |
subtask_1_06.txt | AC | 12 ms | 640 KB |
subtask_1_07.txt | WA | 12 ms | 640 KB |
subtask_1_08.txt | AC | 11 ms | 640 KB |
subtask_1_09.txt | WA | 12 ms | 640 KB |
subtask_1_10.txt | AC | 1 ms | 256 KB |
subtask_1_11.txt | AC | 1 ms | 256 KB |