Submission #1222179
Source Code Expand
#include <iostream> #define MAX_N 100000 using namespace std; int main(void){ int n, a[MAX_N], j; int cnt=0; cin >> n; for (int i=0; i<n; i++){ cin >> a[i]; } for (int i=0; i<n; i++){ if (a[i] != a[i+1]){ j = i; break; } } if (a[j] < a[j+1]){ for (int i=j; i<n; i++){ if (a[i] > a[i+1]){ cnt += 1; for (int k = i; k<n; k++){ if (a[k] < a[k+1]){ i = k; break; } i=k; } } } } else if (a[j] > a[j+1]){ for (int i=j; i<n; i++){ if (a[i] < a[i+1]){ cnt += 1; for (int k = i; k<n; k++){ if (a[k] > a[k+1]){ i = k; break; } i=k; } } } } cout << cnt + 1 << endl; }
Submission Info
Submission Time | |
---|---|
Task | A - Sorted Arrays |
User | sdub |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 849 Byte |
Status | WA |
Exec Time | 55 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 | WA | 33 ms | 512 KB |
subtask_1_02.txt | WA | 26 ms | 384 KB |
subtask_1_03.txt | WA | 17 ms | 384 KB |
subtask_1_04.txt | WA | 53 ms | 640 KB |
subtask_1_05.txt | AC | 54 ms | 640 KB |
subtask_1_06.txt | WA | 53 ms | 640 KB |
subtask_1_07.txt | WA | 55 ms | 640 KB |
subtask_1_08.txt | WA | 53 ms | 640 KB |
subtask_1_09.txt | WA | 55 ms | 640 KB |
subtask_1_10.txt | AC | 1 ms | 256 KB |
subtask_1_11.txt | WA | 1 ms | 256 KB |