# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
166397 | 2019-12-02T04:34:00 Z | abil | Money (IZhO17_money) | C++14 | 2 ms | 376 KB |
#include <bits/stdc++.h> #define fr first #define sc second #define pb push_back #define mk make_pair #define all(s) s.begin(),s.end() #define int long long using namespace std; const int N = (1e6 + 12); const int mod = (1e9 + 7); const int INF = (1e15 + 9); int t[N], a[N], n; void update(int ind){ for(;ind <= n; ind = ind | (ind + 1)){ t[ind]++; } } int get(int pos){ int res = 0; for(;pos >= 1; pos = (pos & (pos + 1)) - 1){ res += t[pos]; } return res; } main() { int ans = 0; cin >> n; for(int i = 1;i <= n; i++){ scanf("%lld", &a[i]); } int pos = 0; for(int i = 1;i <= n; i++){ if(a[i] == a[i + 1]){ continue; } pos++; a[pos] = a[i]; } n = pos; ans++; update(a[n]); for(int i = n - 1;i >= 1; i--){ if(a[i] < a[i + 1]){ if(get(a[i + 1]) - get(a[i]) != a[i + 1] - a[i]){ ans++; } } else{ ans++; } update(a[i]); } cout << ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Incorrect | 2 ms | 376 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Incorrect | 2 ms | 376 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Incorrect | 2 ms | 376 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Incorrect | 2 ms | 376 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |