Submission #1221216
Source Code Expand
#include <bits/stdc++.h> #define REP(i, a, b) for (int i = a; i <= b; ++i) #define PER(i, a, b) for (int i = a; i >= b; --i) #define RVC(i, S) for (int i = 0; i < S.size(); ++i) #define fi first #define se second #define mp make_pair #define pb push_back #define debug(...) fprintf(stderr, __VA_ARGS__) using namespace std; typedef long long LL; typedef pair<int, int> pii; typedef vector<int> VI; inline int read(){ int x = 0, ch = getchar(), f = 1; while (!isdigit(ch)){if (ch == '-') f = -1; ch = getchar();} while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar(); return x * f; } int n, a[100005]; int main(){ n = read(); REP(i, 1, n) a[i] = read(); n = unique(a + 1, a + n + 1) - a - 1; int ans = 0; for (int i = 1, j; i <= n; i = j + 1, ++ans){ if (i == n){ ++ans; break; } j = i; if (i == 7){ ++i, --i; } if (a[j + 1] < a[j]){ while (j + 1 <= n && a[j + 1] < a[j]) ++j; } else{ while (j + 1 <= n && a[j + 1] > a[j]) ++j; } } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Sorted Arrays |
User | zkx06111 |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 1057 Byte |
Status | AC |
Exec Time | 9 ms |
Memory | 640 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 | 6 ms | 512 KB |
subtask_1_02.txt | AC | 5 ms | 384 KB |
subtask_1_03.txt | AC | 3 ms | 384 KB |
subtask_1_04.txt | AC | 9 ms | 640 KB |
subtask_1_05.txt | AC | 8 ms | 640 KB |
subtask_1_06.txt | AC | 9 ms | 640 KB |
subtask_1_07.txt | AC | 9 ms | 640 KB |
subtask_1_08.txt | AC | 9 ms | 640 KB |
subtask_1_09.txt | AC | 9 ms | 640 KB |
subtask_1_10.txt | AC | 1 ms | 256 KB |
subtask_1_11.txt | AC | 1 ms | 256 KB |