Submission #1794813
Source Code Expand
#include <bits/stdc++.h> using namespace std; int a[100001]; int d1[100001]; int d[100001]; main () { ios_base::sync_with_stdio (0); cin.tie (0); int n, n1; cin >> n1; if (n1 == 1) { cout << 1; return 0; } int kol = 0, kol1 = 0; int ok = 1; for (int i = 1;i <= n1;i ++) { int x; cin >> x; if (a[n] != x) { n ++; a[n] = x; } } for (int i = 1;i <= n;i ++) { if (n == i) { d[i] = d[i - 1]; continue; } if (a[i] < a[i + 1]) { d[i] = 1; } else d[i] = -1; } for (int i = 1;i <= n;i ++) { if (d[i] != d[i - 1] && d[i - 1] != 2) { kol ++; // cout << i << ' '; if (i != 1) d[i] = 2; } } cout << kol; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Sorted Arrays |
User | almasalmas |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 749 Byte |
Status | AC |
Exec Time | 12 ms |
Memory | 1024 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 | 8 ms | 768 KB |
subtask_1_02.txt | AC | 6 ms | 640 KB |
subtask_1_03.txt | AC | 4 ms | 512 KB |
subtask_1_04.txt | AC | 12 ms | 1024 KB |
subtask_1_05.txt | AC | 11 ms | 1024 KB |
subtask_1_06.txt | AC | 12 ms | 1024 KB |
subtask_1_07.txt | AC | 12 ms | 1024 KB |
subtask_1_08.txt | AC | 11 ms | 256 KB |
subtask_1_09.txt | AC | 12 ms | 1024 KB |
subtask_1_10.txt | AC | 1 ms | 256 KB |
subtask_1_11.txt | AC | 1 ms | 256 KB |