#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;
cin >> n;
for(int i=0; i<n; i++){
cin >> x;
if(x<last || get(x)!=get(last)) res++;
last=x;
update(x, 1);
}
cout << res;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
4276 KB |
Output is correct |
2 |
Correct |
7 ms |
4328 KB |
Output is correct |
3 |
Correct |
7 ms |
4444 KB |
Output is correct |
4 |
Incorrect |
7 ms |
4444 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
4276 KB |
Output is correct |
2 |
Correct |
7 ms |
4328 KB |
Output is correct |
3 |
Correct |
7 ms |
4444 KB |
Output is correct |
4 |
Incorrect |
7 ms |
4444 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
4276 KB |
Output is correct |
2 |
Correct |
7 ms |
4328 KB |
Output is correct |
3 |
Correct |
7 ms |
4444 KB |
Output is correct |
4 |
Incorrect |
7 ms |
4444 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
4276 KB |
Output is correct |
2 |
Correct |
7 ms |
4328 KB |
Output is correct |
3 |
Correct |
7 ms |
4444 KB |
Output is correct |
4 |
Incorrect |
7 ms |
4444 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |