# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
60417 |
2018-07-24T06:58:25 Z |
Tenuun |
Money (IZhO17_money) |
C++17 |
|
7 ms |
4512 KB |
#include<bits/stdc++.h>
using namespace std;
int tr[1000001];
void update(int ind, int val){
while(ind<=1000000){
tr[ind]+=val;
ind+=ind&-ind;
}
}
int get(int ind){
int ans=0;
while(ind){
ans+=tr[ind];
ind-=ind&-ind;
}
return ans;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
memset(tr, 0, sizeof tr);
int n, last=0, res=1, x, start=0, cnt=1;
cin >> n;
for(int i=0; i<n; i++){
cin >> x;
if(x<last || (abs(x-start)>1 && get(x-1)-get(start)>cnt-1)) {
res++;
start=x;
cnt=1;
//cout << i << " ";
}
else cnt++;
last=x;
update(x, 1);
}
cout << res;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
4216 KB |
Output is correct |
2 |
Correct |
6 ms |
4352 KB |
Output is correct |
3 |
Correct |
6 ms |
4428 KB |
Output is correct |
4 |
Correct |
6 ms |
4428 KB |
Output is correct |
5 |
Correct |
5 ms |
4428 KB |
Output is correct |
6 |
Correct |
6 ms |
4512 KB |
Output is correct |
7 |
Correct |
5 ms |
4512 KB |
Output is correct |
8 |
Correct |
7 ms |
4512 KB |
Output is correct |
9 |
Correct |
5 ms |
4512 KB |
Output is correct |
10 |
Correct |
7 ms |
4512 KB |
Output is correct |
11 |
Correct |
6 ms |
4512 KB |
Output is correct |
12 |
Correct |
6 ms |
4512 KB |
Output is correct |
13 |
Correct |
5 ms |
4512 KB |
Output is correct |
14 |
Correct |
7 ms |
4512 KB |
Output is correct |
15 |
Correct |
7 ms |
4512 KB |
Output is correct |
16 |
Correct |
7 ms |
4512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
4216 KB |
Output is correct |
2 |
Correct |
6 ms |
4352 KB |
Output is correct |
3 |
Correct |
6 ms |
4428 KB |
Output is correct |
4 |
Correct |
6 ms |
4428 KB |
Output is correct |
5 |
Correct |
5 ms |
4428 KB |
Output is correct |
6 |
Correct |
6 ms |
4512 KB |
Output is correct |
7 |
Correct |
5 ms |
4512 KB |
Output is correct |
8 |
Correct |
7 ms |
4512 KB |
Output is correct |
9 |
Correct |
5 ms |
4512 KB |
Output is correct |
10 |
Correct |
7 ms |
4512 KB |
Output is correct |
11 |
Correct |
6 ms |
4512 KB |
Output is correct |
12 |
Correct |
6 ms |
4512 KB |
Output is correct |
13 |
Correct |
5 ms |
4512 KB |
Output is correct |
14 |
Correct |
7 ms |
4512 KB |
Output is correct |
15 |
Correct |
7 ms |
4512 KB |
Output is correct |
16 |
Correct |
7 ms |
4512 KB |
Output is correct |
17 |
Correct |
7 ms |
4512 KB |
Output is correct |
18 |
Correct |
2 ms |
4512 KB |
Output is correct |
19 |
Correct |
6 ms |
4512 KB |
Output is correct |
20 |
Incorrect |
6 ms |
4512 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
4216 KB |
Output is correct |
2 |
Correct |
6 ms |
4352 KB |
Output is correct |
3 |
Correct |
6 ms |
4428 KB |
Output is correct |
4 |
Correct |
6 ms |
4428 KB |
Output is correct |
5 |
Correct |
5 ms |
4428 KB |
Output is correct |
6 |
Correct |
6 ms |
4512 KB |
Output is correct |
7 |
Correct |
5 ms |
4512 KB |
Output is correct |
8 |
Correct |
7 ms |
4512 KB |
Output is correct |
9 |
Correct |
5 ms |
4512 KB |
Output is correct |
10 |
Correct |
7 ms |
4512 KB |
Output is correct |
11 |
Correct |
6 ms |
4512 KB |
Output is correct |
12 |
Correct |
6 ms |
4512 KB |
Output is correct |
13 |
Correct |
5 ms |
4512 KB |
Output is correct |
14 |
Correct |
7 ms |
4512 KB |
Output is correct |
15 |
Correct |
7 ms |
4512 KB |
Output is correct |
16 |
Correct |
7 ms |
4512 KB |
Output is correct |
17 |
Correct |
7 ms |
4512 KB |
Output is correct |
18 |
Correct |
2 ms |
4512 KB |
Output is correct |
19 |
Correct |
6 ms |
4512 KB |
Output is correct |
20 |
Incorrect |
6 ms |
4512 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
4216 KB |
Output is correct |
2 |
Correct |
6 ms |
4352 KB |
Output is correct |
3 |
Correct |
6 ms |
4428 KB |
Output is correct |
4 |
Correct |
6 ms |
4428 KB |
Output is correct |
5 |
Correct |
5 ms |
4428 KB |
Output is correct |
6 |
Correct |
6 ms |
4512 KB |
Output is correct |
7 |
Correct |
5 ms |
4512 KB |
Output is correct |
8 |
Correct |
7 ms |
4512 KB |
Output is correct |
9 |
Correct |
5 ms |
4512 KB |
Output is correct |
10 |
Correct |
7 ms |
4512 KB |
Output is correct |
11 |
Correct |
6 ms |
4512 KB |
Output is correct |
12 |
Correct |
6 ms |
4512 KB |
Output is correct |
13 |
Correct |
5 ms |
4512 KB |
Output is correct |
14 |
Correct |
7 ms |
4512 KB |
Output is correct |
15 |
Correct |
7 ms |
4512 KB |
Output is correct |
16 |
Correct |
7 ms |
4512 KB |
Output is correct |
17 |
Correct |
7 ms |
4512 KB |
Output is correct |
18 |
Correct |
2 ms |
4512 KB |
Output is correct |
19 |
Correct |
6 ms |
4512 KB |
Output is correct |
20 |
Incorrect |
6 ms |
4512 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |