# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
35191 | 2017-11-18T16:20:12 Z | ulna | Money (IZhO17_money) | C++11 | 0 ms | 9828 KB |
#include <bits/stdc++.h> using namespace std; // why am I so weak int n; int a[1000055]; int dat[1000055]; inline void read(int &x) { x = 0; char ch = 0; while (ch < '0' || ch > '9') ch = getchar(); while (ch >= '0' && ch <= '9') { x = x * 10 + (ch - '0'); ch = getchar(); } } void add(int id) { while (id <= (int)1e6) { dat[id]++; id += id & -id; } } int get(int id) { int res = 0; while (id > 0) { res += dat[id]; id -= id & -id; } return res; } int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { read(a[i]); } int res = 1; add(a[0]); for (int i = 0; i + 1 < n; i++) { add(a[i + 1]); if (a[i + 1] < a[i]) { res++; continue; } if (a[i + 1] == a[i]) continue; if (get(a[i + 1] - 1) - get(a[i]) > 0) { res++; } } printf("%d\n", res); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 9828 KB | Output is correct |
2 | Correct | 0 ms | 9828 KB | Output is correct |
3 | Correct | 0 ms | 9828 KB | Output is correct |
4 | Correct | 0 ms | 9828 KB | Output is correct |
5 | Correct | 0 ms | 9828 KB | Output is correct |
6 | Correct | 0 ms | 9828 KB | Output is correct |
7 | Correct | 0 ms | 9828 KB | Output is correct |
8 | Correct | 0 ms | 9828 KB | Output is correct |
9 | Correct | 0 ms | 9828 KB | Output is correct |
10 | Correct | 0 ms | 9828 KB | Output is correct |
11 | Correct | 0 ms | 9828 KB | Output is correct |
12 | Incorrect | 0 ms | 9828 KB | Output isn't correct |
13 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 9828 KB | Output is correct |
2 | Correct | 0 ms | 9828 KB | Output is correct |
3 | Correct | 0 ms | 9828 KB | Output is correct |
4 | Correct | 0 ms | 9828 KB | Output is correct |
5 | Correct | 0 ms | 9828 KB | Output is correct |
6 | Correct | 0 ms | 9828 KB | Output is correct |
7 | Correct | 0 ms | 9828 KB | Output is correct |
8 | Correct | 0 ms | 9828 KB | Output is correct |
9 | Correct | 0 ms | 9828 KB | Output is correct |
10 | Correct | 0 ms | 9828 KB | Output is correct |
11 | Correct | 0 ms | 9828 KB | Output is correct |
12 | Incorrect | 0 ms | 9828 KB | Output isn't correct |
13 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 9828 KB | Output is correct |
2 | Correct | 0 ms | 9828 KB | Output is correct |
3 | Correct | 0 ms | 9828 KB | Output is correct |
4 | Correct | 0 ms | 9828 KB | Output is correct |
5 | Correct | 0 ms | 9828 KB | Output is correct |
6 | Correct | 0 ms | 9828 KB | Output is correct |
7 | Correct | 0 ms | 9828 KB | Output is correct |
8 | Correct | 0 ms | 9828 KB | Output is correct |
9 | Correct | 0 ms | 9828 KB | Output is correct |
10 | Correct | 0 ms | 9828 KB | Output is correct |
11 | Correct | 0 ms | 9828 KB | Output is correct |
12 | Incorrect | 0 ms | 9828 KB | Output isn't correct |
13 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 9828 KB | Output is correct |
2 | Correct | 0 ms | 9828 KB | Output is correct |
3 | Correct | 0 ms | 9828 KB | Output is correct |
4 | Correct | 0 ms | 9828 KB | Output is correct |
5 | Correct | 0 ms | 9828 KB | Output is correct |
6 | Correct | 0 ms | 9828 KB | Output is correct |
7 | Correct | 0 ms | 9828 KB | Output is correct |
8 | Correct | 0 ms | 9828 KB | Output is correct |
9 | Correct | 0 ms | 9828 KB | Output is correct |
10 | Correct | 0 ms | 9828 KB | Output is correct |
11 | Correct | 0 ms | 9828 KB | Output is correct |
12 | Incorrect | 0 ms | 9828 KB | Output isn't correct |
13 | Halted | 0 ms | 0 KB | - |