#include<bits/stdc++.h>
#include "towers.h"
using namespace std;
int a,b,c,d,e,i,j,ii,jj,zx,xc,f[100009],pas,L,R,D,dp[100009],fen[200009],K[100009],HD[1000009],fen2[200009];
map <int, int> m;
map <int, int>::iterator it;
void init(int NN, std::vector<int> HH) {
a=NN;
for(i=1; i<=a; i++){
f[i]=HH[i-1];
}
}
void upd(int q, int w){
while(q<=200005){
fen[q]=max(fen[q],w);
q=q+(q&(-q));
}
}
int read(int q){
int sm=0;
while(q>0){
sm=max(sm,fen[q]);
q=q-(q&(-q));
}
return sm;
}
void upd2(int q, int w){
q=200003-q;
while(q<=200005){
fen2[q]=max(fen2[q],w);
q=q+(q&(-q));
}
}
int read2(int q){
q=200003-q;
int sm=0;
while(q>0){
sm=max(sm,fen2[q]);
q=q-(q&(-q));
}
return sm;
}
int max_towers(int LL, int RR, int DD) {
pas=1;LL++;RR++;
L=LL;R=RR;D=DD;
for(i=1; i<=R-L+1; i++){
f[i]=f[i+L-1];
}
a=R-L+1;
for(i=1; i<=a; i++){
//cout<<f[i]<<" ";
m[f[i]]=1;m[f[i]+D]=1;
}
zx=0;
for(it=m.begin(); it!=m.end(); it++){
zx++;
(*it).second=zx;
}
for(i=1; i<=a; i++){
HD[i]=m[f[i]+D];
K[i]=m[f[i]];
}
for(i=1; i<=a; i++){
dp[i]=read2(HD[i])+1;
zx=read(K[i]);
/*cout<<i<<" "<<zx<<"\n";
cout<<K[i]<<" "<<HD[i]<<"\n";*/
upd2(K[i],zx);
upd(HD[i],dp[i]);
}
for(i=1; i<=a; i++){
pas=max(pas,dp[i]);
}
return pas;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4051 ms |
23468 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
464 KB |
Output is correct |
3 |
Correct |
1 ms |
464 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
476 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
464 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
464 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
464 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
2 ms |
592 KB |
Output is correct |
21 |
Correct |
1 ms |
592 KB |
Output is correct |
22 |
Correct |
2 ms |
592 KB |
Output is correct |
23 |
Correct |
1 ms |
592 KB |
Output is correct |
24 |
Correct |
1 ms |
592 KB |
Output is correct |
25 |
Correct |
1 ms |
464 KB |
Output is correct |
26 |
Correct |
2 ms |
592 KB |
Output is correct |
27 |
Correct |
2 ms |
592 KB |
Output is correct |
28 |
Correct |
2 ms |
592 KB |
Output is correct |
29 |
Correct |
2 ms |
592 KB |
Output is correct |
30 |
Correct |
2 ms |
592 KB |
Output is correct |
31 |
Correct |
2 ms |
592 KB |
Output is correct |
32 |
Correct |
1 ms |
592 KB |
Output is correct |
33 |
Correct |
1 ms |
592 KB |
Output is correct |
34 |
Correct |
1 ms |
592 KB |
Output is correct |
35 |
Correct |
1 ms |
592 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
464 KB |
Output is correct |
3 |
Correct |
1 ms |
464 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
476 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
464 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
464 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
464 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
2 ms |
592 KB |
Output is correct |
21 |
Correct |
1 ms |
592 KB |
Output is correct |
22 |
Correct |
2 ms |
592 KB |
Output is correct |
23 |
Correct |
1 ms |
592 KB |
Output is correct |
24 |
Correct |
1 ms |
592 KB |
Output is correct |
25 |
Correct |
1 ms |
464 KB |
Output is correct |
26 |
Correct |
2 ms |
592 KB |
Output is correct |
27 |
Correct |
2 ms |
592 KB |
Output is correct |
28 |
Correct |
2 ms |
592 KB |
Output is correct |
29 |
Correct |
2 ms |
592 KB |
Output is correct |
30 |
Correct |
2 ms |
592 KB |
Output is correct |
31 |
Correct |
2 ms |
592 KB |
Output is correct |
32 |
Correct |
1 ms |
592 KB |
Output is correct |
33 |
Correct |
1 ms |
592 KB |
Output is correct |
34 |
Correct |
1 ms |
592 KB |
Output is correct |
35 |
Correct |
1 ms |
592 KB |
Output is correct |
36 |
Correct |
19 ms |
3064 KB |
Output is correct |
37 |
Correct |
37 ms |
5160 KB |
Output is correct |
38 |
Correct |
22 ms |
2740 KB |
Output is correct |
39 |
Correct |
32 ms |
4768 KB |
Output is correct |
40 |
Correct |
22 ms |
2588 KB |
Output is correct |
41 |
Correct |
105 ms |
10804 KB |
Output is correct |
42 |
Correct |
10 ms |
1472 KB |
Output is correct |
43 |
Correct |
34 ms |
7064 KB |
Output is correct |
44 |
Correct |
21 ms |
2596 KB |
Output is correct |
45 |
Correct |
9 ms |
1488 KB |
Output is correct |
46 |
Correct |
9 ms |
1352 KB |
Output is correct |
47 |
Correct |
40 ms |
5380 KB |
Output is correct |
48 |
Correct |
24 ms |
3596 KB |
Output is correct |
49 |
Correct |
13 ms |
2112 KB |
Output is correct |
50 |
Correct |
24 ms |
3648 KB |
Output is correct |
51 |
Correct |
26 ms |
5888 KB |
Output is correct |
52 |
Correct |
95 ms |
13132 KB |
Output is correct |
53 |
Correct |
94 ms |
13152 KB |
Output is correct |
54 |
Correct |
93 ms |
13168 KB |
Output is correct |
55 |
Correct |
64 ms |
13144 KB |
Output is correct |
56 |
Correct |
58 ms |
13176 KB |
Output is correct |
57 |
Correct |
106 ms |
12236 KB |
Output is correct |
58 |
Correct |
152 ms |
12876 KB |
Output is correct |
59 |
Correct |
124 ms |
12960 KB |
Output is correct |
60 |
Correct |
137 ms |
13184 KB |
Output is correct |
61 |
Correct |
125 ms |
13012 KB |
Output is correct |
62 |
Correct |
125 ms |
12860 KB |
Output is correct |
63 |
Correct |
120 ms |
12964 KB |
Output is correct |
64 |
Correct |
64 ms |
12744 KB |
Output is correct |
65 |
Correct |
64 ms |
12720 KB |
Output is correct |
66 |
Correct |
60 ms |
12992 KB |
Output is correct |
67 |
Correct |
61 ms |
12720 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4019 ms |
11296 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
357 ms |
33972 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
464 KB |
Output is correct |
3 |
Correct |
1 ms |
464 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
476 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
464 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
464 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
464 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
2 ms |
592 KB |
Output is correct |
21 |
Correct |
1 ms |
592 KB |
Output is correct |
22 |
Correct |
2 ms |
592 KB |
Output is correct |
23 |
Correct |
1 ms |
592 KB |
Output is correct |
24 |
Correct |
1 ms |
592 KB |
Output is correct |
25 |
Correct |
1 ms |
464 KB |
Output is correct |
26 |
Correct |
2 ms |
592 KB |
Output is correct |
27 |
Correct |
2 ms |
592 KB |
Output is correct |
28 |
Correct |
2 ms |
592 KB |
Output is correct |
29 |
Correct |
2 ms |
592 KB |
Output is correct |
30 |
Correct |
2 ms |
592 KB |
Output is correct |
31 |
Correct |
2 ms |
592 KB |
Output is correct |
32 |
Correct |
1 ms |
592 KB |
Output is correct |
33 |
Correct |
1 ms |
592 KB |
Output is correct |
34 |
Correct |
1 ms |
592 KB |
Output is correct |
35 |
Correct |
1 ms |
592 KB |
Output is correct |
36 |
Correct |
19 ms |
3064 KB |
Output is correct |
37 |
Correct |
37 ms |
5160 KB |
Output is correct |
38 |
Correct |
22 ms |
2740 KB |
Output is correct |
39 |
Correct |
32 ms |
4768 KB |
Output is correct |
40 |
Correct |
22 ms |
2588 KB |
Output is correct |
41 |
Correct |
105 ms |
10804 KB |
Output is correct |
42 |
Correct |
10 ms |
1472 KB |
Output is correct |
43 |
Correct |
34 ms |
7064 KB |
Output is correct |
44 |
Correct |
21 ms |
2596 KB |
Output is correct |
45 |
Correct |
9 ms |
1488 KB |
Output is correct |
46 |
Correct |
9 ms |
1352 KB |
Output is correct |
47 |
Correct |
40 ms |
5380 KB |
Output is correct |
48 |
Correct |
24 ms |
3596 KB |
Output is correct |
49 |
Correct |
13 ms |
2112 KB |
Output is correct |
50 |
Correct |
24 ms |
3648 KB |
Output is correct |
51 |
Correct |
26 ms |
5888 KB |
Output is correct |
52 |
Correct |
95 ms |
13132 KB |
Output is correct |
53 |
Correct |
94 ms |
13152 KB |
Output is correct |
54 |
Correct |
93 ms |
13168 KB |
Output is correct |
55 |
Correct |
64 ms |
13144 KB |
Output is correct |
56 |
Correct |
58 ms |
13176 KB |
Output is correct |
57 |
Correct |
106 ms |
12236 KB |
Output is correct |
58 |
Correct |
152 ms |
12876 KB |
Output is correct |
59 |
Correct |
124 ms |
12960 KB |
Output is correct |
60 |
Correct |
137 ms |
13184 KB |
Output is correct |
61 |
Correct |
125 ms |
13012 KB |
Output is correct |
62 |
Correct |
125 ms |
12860 KB |
Output is correct |
63 |
Correct |
120 ms |
12964 KB |
Output is correct |
64 |
Correct |
64 ms |
12744 KB |
Output is correct |
65 |
Correct |
64 ms |
12720 KB |
Output is correct |
66 |
Correct |
60 ms |
12992 KB |
Output is correct |
67 |
Correct |
61 ms |
12720 KB |
Output is correct |
68 |
Execution timed out |
4019 ms |
11296 KB |
Time limit exceeded |
69 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4051 ms |
23468 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |