#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,i,j,ii,jj,zx,xc,f[1000009],dp[1000009],g[1000009],fen[1000009],L[1000009];
map <int, int> m;
map <int, int>::iterator it;
void upd(int q, int w){
q=1000004-q;
while(q<=1000005){
fen[q]=min(fen[q],w);
q=q+(q&(-q));
}
}
int read(int q){
q=1000004-q;
int sm=1000009;
while(q>=1){
sm=min(sm,fen[q]);
q=q-(q&(-q));
}
return sm;
}
void upd2(int q, int w){
while(q<=1000005){
fen[q]=max(fen[q],w);
q=q+(q&(-q));
}
}
int read2(int q){
int sm=0;
while(q>=1){
sm=max(sm,fen[q]);
q=q-(q&(-q));
}
return sm;
}
int main(){
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>a;
for(i=1; i<=a; i++) cin>>f[i];
for(i=0; i<=1000007; i++){
fen[i]=1000009;
}
for(i=1; i<=a; i++){
g[i]=read(f[i]+1);
g[i]=min(g[i],1000001);
upd(f[i],f[i]);
}
L[1]=1;
for(i=2; i<=a; i++){
if(f[i]<f[i-1]){
L[i]=i;
}else{
L[i]=L[i-1];
}
}
for(i=0; i<=1000007; i++){
fen[i]=0;
}
for(i=1; i<=a; i++){
c=read2(f[i]-1);
c=max(c+1,L[i]);
dp[i]=dp[c-1]+1;
upd2(g[i],i);
}
cout<<dp[a];
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4172 KB |
Output is correct |
2 |
Correct |
2 ms |
4224 KB |
Output is correct |
3 |
Correct |
3 ms |
4172 KB |
Output is correct |
4 |
Correct |
3 ms |
4172 KB |
Output is correct |
5 |
Correct |
2 ms |
4172 KB |
Output is correct |
6 |
Correct |
2 ms |
4172 KB |
Output is correct |
7 |
Correct |
2 ms |
4172 KB |
Output is correct |
8 |
Correct |
3 ms |
4172 KB |
Output is correct |
9 |
Correct |
2 ms |
4172 KB |
Output is correct |
10 |
Correct |
2 ms |
4172 KB |
Output is correct |
11 |
Correct |
2 ms |
4172 KB |
Output is correct |
12 |
Correct |
2 ms |
4172 KB |
Output is correct |
13 |
Correct |
3 ms |
4172 KB |
Output is correct |
14 |
Correct |
2 ms |
4172 KB |
Output is correct |
15 |
Correct |
2 ms |
4172 KB |
Output is correct |
16 |
Correct |
2 ms |
4172 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4172 KB |
Output is correct |
2 |
Correct |
2 ms |
4224 KB |
Output is correct |
3 |
Correct |
3 ms |
4172 KB |
Output is correct |
4 |
Correct |
3 ms |
4172 KB |
Output is correct |
5 |
Correct |
2 ms |
4172 KB |
Output is correct |
6 |
Correct |
2 ms |
4172 KB |
Output is correct |
7 |
Correct |
2 ms |
4172 KB |
Output is correct |
8 |
Correct |
3 ms |
4172 KB |
Output is correct |
9 |
Correct |
2 ms |
4172 KB |
Output is correct |
10 |
Correct |
2 ms |
4172 KB |
Output is correct |
11 |
Correct |
2 ms |
4172 KB |
Output is correct |
12 |
Correct |
2 ms |
4172 KB |
Output is correct |
13 |
Correct |
3 ms |
4172 KB |
Output is correct |
14 |
Correct |
2 ms |
4172 KB |
Output is correct |
15 |
Correct |
2 ms |
4172 KB |
Output is correct |
16 |
Correct |
2 ms |
4172 KB |
Output is correct |
17 |
Correct |
2 ms |
4172 KB |
Output is correct |
18 |
Correct |
2 ms |
4172 KB |
Output is correct |
19 |
Correct |
2 ms |
4172 KB |
Output is correct |
20 |
Correct |
2 ms |
4172 KB |
Output is correct |
21 |
Correct |
4 ms |
4172 KB |
Output is correct |
22 |
Correct |
2 ms |
4172 KB |
Output is correct |
23 |
Correct |
3 ms |
4232 KB |
Output is correct |
24 |
Correct |
2 ms |
4172 KB |
Output is correct |
25 |
Correct |
2 ms |
4172 KB |
Output is correct |
26 |
Correct |
2 ms |
4172 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4172 KB |
Output is correct |
2 |
Correct |
2 ms |
4224 KB |
Output is correct |
3 |
Correct |
3 ms |
4172 KB |
Output is correct |
4 |
Correct |
3 ms |
4172 KB |
Output is correct |
5 |
Correct |
2 ms |
4172 KB |
Output is correct |
6 |
Correct |
2 ms |
4172 KB |
Output is correct |
7 |
Correct |
2 ms |
4172 KB |
Output is correct |
8 |
Correct |
3 ms |
4172 KB |
Output is correct |
9 |
Correct |
2 ms |
4172 KB |
Output is correct |
10 |
Correct |
2 ms |
4172 KB |
Output is correct |
11 |
Correct |
2 ms |
4172 KB |
Output is correct |
12 |
Correct |
2 ms |
4172 KB |
Output is correct |
13 |
Correct |
3 ms |
4172 KB |
Output is correct |
14 |
Correct |
2 ms |
4172 KB |
Output is correct |
15 |
Correct |
2 ms |
4172 KB |
Output is correct |
16 |
Correct |
2 ms |
4172 KB |
Output is correct |
17 |
Correct |
2 ms |
4172 KB |
Output is correct |
18 |
Correct |
2 ms |
4172 KB |
Output is correct |
19 |
Correct |
2 ms |
4172 KB |
Output is correct |
20 |
Correct |
2 ms |
4172 KB |
Output is correct |
21 |
Correct |
4 ms |
4172 KB |
Output is correct |
22 |
Correct |
2 ms |
4172 KB |
Output is correct |
23 |
Correct |
3 ms |
4232 KB |
Output is correct |
24 |
Correct |
2 ms |
4172 KB |
Output is correct |
25 |
Correct |
2 ms |
4172 KB |
Output is correct |
26 |
Correct |
2 ms |
4172 KB |
Output is correct |
27 |
Correct |
2 ms |
4172 KB |
Output is correct |
28 |
Correct |
2 ms |
4172 KB |
Output is correct |
29 |
Correct |
3 ms |
4172 KB |
Output is correct |
30 |
Correct |
2 ms |
4172 KB |
Output is correct |
31 |
Correct |
2 ms |
4172 KB |
Output is correct |
32 |
Correct |
2 ms |
4172 KB |
Output is correct |
33 |
Correct |
2 ms |
4172 KB |
Output is correct |
34 |
Correct |
2 ms |
4220 KB |
Output is correct |
35 |
Correct |
2 ms |
4172 KB |
Output is correct |
36 |
Correct |
4 ms |
4172 KB |
Output is correct |
37 |
Correct |
3 ms |
4172 KB |
Output is correct |
38 |
Correct |
4 ms |
4252 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4172 KB |
Output is correct |
2 |
Correct |
2 ms |
4224 KB |
Output is correct |
3 |
Correct |
3 ms |
4172 KB |
Output is correct |
4 |
Correct |
3 ms |
4172 KB |
Output is correct |
5 |
Correct |
2 ms |
4172 KB |
Output is correct |
6 |
Correct |
2 ms |
4172 KB |
Output is correct |
7 |
Correct |
2 ms |
4172 KB |
Output is correct |
8 |
Correct |
3 ms |
4172 KB |
Output is correct |
9 |
Correct |
2 ms |
4172 KB |
Output is correct |
10 |
Correct |
2 ms |
4172 KB |
Output is correct |
11 |
Correct |
2 ms |
4172 KB |
Output is correct |
12 |
Correct |
2 ms |
4172 KB |
Output is correct |
13 |
Correct |
3 ms |
4172 KB |
Output is correct |
14 |
Correct |
2 ms |
4172 KB |
Output is correct |
15 |
Correct |
2 ms |
4172 KB |
Output is correct |
16 |
Correct |
2 ms |
4172 KB |
Output is correct |
17 |
Correct |
2 ms |
4172 KB |
Output is correct |
18 |
Correct |
2 ms |
4172 KB |
Output is correct |
19 |
Correct |
2 ms |
4172 KB |
Output is correct |
20 |
Correct |
2 ms |
4172 KB |
Output is correct |
21 |
Correct |
4 ms |
4172 KB |
Output is correct |
22 |
Correct |
2 ms |
4172 KB |
Output is correct |
23 |
Correct |
3 ms |
4232 KB |
Output is correct |
24 |
Correct |
2 ms |
4172 KB |
Output is correct |
25 |
Correct |
2 ms |
4172 KB |
Output is correct |
26 |
Correct |
2 ms |
4172 KB |
Output is correct |
27 |
Correct |
2 ms |
4172 KB |
Output is correct |
28 |
Correct |
2 ms |
4172 KB |
Output is correct |
29 |
Correct |
3 ms |
4172 KB |
Output is correct |
30 |
Correct |
2 ms |
4172 KB |
Output is correct |
31 |
Correct |
2 ms |
4172 KB |
Output is correct |
32 |
Correct |
2 ms |
4172 KB |
Output is correct |
33 |
Correct |
2 ms |
4172 KB |
Output is correct |
34 |
Correct |
2 ms |
4220 KB |
Output is correct |
35 |
Correct |
2 ms |
4172 KB |
Output is correct |
36 |
Correct |
4 ms |
4172 KB |
Output is correct |
37 |
Correct |
3 ms |
4172 KB |
Output is correct |
38 |
Correct |
4 ms |
4252 KB |
Output is correct |
39 |
Correct |
76 ms |
11644 KB |
Output is correct |
40 |
Correct |
131 ms |
21812 KB |
Output is correct |
41 |
Correct |
65 ms |
12820 KB |
Output is correct |
42 |
Correct |
57 ms |
11896 KB |
Output is correct |
43 |
Correct |
43 ms |
9648 KB |
Output is correct |
44 |
Correct |
164 ms |
26540 KB |
Output is correct |
45 |
Correct |
182 ms |
26432 KB |
Output is correct |
46 |
Correct |
163 ms |
26676 KB |
Output is correct |
47 |
Correct |
144 ms |
26608 KB |
Output is correct |
48 |
Correct |
152 ms |
26716 KB |
Output is correct |
49 |
Correct |
169 ms |
26552 KB |
Output is correct |
50 |
Correct |
171 ms |
26692 KB |
Output is correct |
51 |
Correct |
170 ms |
26568 KB |
Output is correct |
52 |
Correct |
187 ms |
26640 KB |
Output is correct |
53 |
Correct |
173 ms |
26628 KB |
Output is correct |
54 |
Correct |
183 ms |
26468 KB |
Output is correct |
55 |
Correct |
188 ms |
26548 KB |
Output is correct |
56 |
Correct |
181 ms |
26520 KB |
Output is correct |
57 |
Correct |
180 ms |
26564 KB |
Output is correct |
58 |
Correct |
181 ms |
26564 KB |
Output is correct |
59 |
Correct |
179 ms |
26476 KB |
Output is correct |
60 |
Correct |
185 ms |
26564 KB |
Output is correct |
61 |
Correct |
191 ms |
26476 KB |
Output is correct |
62 |
Correct |
173 ms |
26588 KB |
Output is correct |