#include <bits/stdc++.h>
using namespace std;
int n,a[1000005],tree[1000005];
void Update(int idx)
{
while(idx<=1e6)
{
tree[idx]++;
idx+=idx&-idx;
}
}
int Query(int idx)
{
int rs=0;
while(idx>0)
{
rs+=tree[idx];
idx-=idx&-idx;
}
return rs;
}
int main()
{
ios_base::sync_with_stdio(false);
//freopen("TEST.INP","r",stdin);
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i];
int res=1,pre=1;
for(int i=2;i<=n;i++)
if(a[i]<a[i-1]||Query(a[i]-1)-Query(a[i-1])>0)
{
res++;
for(int j=pre;j<i;j++)
Update(a[j]);
pre=i;
}
cout<<res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
9988 KB |
Output is correct |
2 |
Correct |
0 ms |
9988 KB |
Output is correct |
3 |
Correct |
0 ms |
9988 KB |
Output is correct |
4 |
Correct |
0 ms |
9988 KB |
Output is correct |
5 |
Correct |
0 ms |
9988 KB |
Output is correct |
6 |
Correct |
0 ms |
9988 KB |
Output is correct |
7 |
Correct |
0 ms |
9988 KB |
Output is correct |
8 |
Correct |
0 ms |
9988 KB |
Output is correct |
9 |
Correct |
0 ms |
9988 KB |
Output is correct |
10 |
Correct |
0 ms |
9988 KB |
Output is correct |
11 |
Correct |
0 ms |
9988 KB |
Output is correct |
12 |
Incorrect |
0 ms |
9988 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
9988 KB |
Output is correct |
2 |
Correct |
0 ms |
9988 KB |
Output is correct |
3 |
Correct |
0 ms |
9988 KB |
Output is correct |
4 |
Correct |
0 ms |
9988 KB |
Output is correct |
5 |
Correct |
0 ms |
9988 KB |
Output is correct |
6 |
Correct |
0 ms |
9988 KB |
Output is correct |
7 |
Correct |
0 ms |
9988 KB |
Output is correct |
8 |
Correct |
0 ms |
9988 KB |
Output is correct |
9 |
Correct |
0 ms |
9988 KB |
Output is correct |
10 |
Correct |
0 ms |
9988 KB |
Output is correct |
11 |
Correct |
0 ms |
9988 KB |
Output is correct |
12 |
Incorrect |
0 ms |
9988 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
9988 KB |
Output is correct |
2 |
Correct |
0 ms |
9988 KB |
Output is correct |
3 |
Correct |
0 ms |
9988 KB |
Output is correct |
4 |
Correct |
0 ms |
9988 KB |
Output is correct |
5 |
Correct |
0 ms |
9988 KB |
Output is correct |
6 |
Correct |
0 ms |
9988 KB |
Output is correct |
7 |
Correct |
0 ms |
9988 KB |
Output is correct |
8 |
Correct |
0 ms |
9988 KB |
Output is correct |
9 |
Correct |
0 ms |
9988 KB |
Output is correct |
10 |
Correct |
0 ms |
9988 KB |
Output is correct |
11 |
Correct |
0 ms |
9988 KB |
Output is correct |
12 |
Incorrect |
0 ms |
9988 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
9988 KB |
Output is correct |
2 |
Correct |
0 ms |
9988 KB |
Output is correct |
3 |
Correct |
0 ms |
9988 KB |
Output is correct |
4 |
Correct |
0 ms |
9988 KB |
Output is correct |
5 |
Correct |
0 ms |
9988 KB |
Output is correct |
6 |
Correct |
0 ms |
9988 KB |
Output is correct |
7 |
Correct |
0 ms |
9988 KB |
Output is correct |
8 |
Correct |
0 ms |
9988 KB |
Output is correct |
9 |
Correct |
0 ms |
9988 KB |
Output is correct |
10 |
Correct |
0 ms |
9988 KB |
Output is correct |
11 |
Correct |
0 ms |
9988 KB |
Output is correct |
12 |
Incorrect |
0 ms |
9988 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |