# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
626226 | 2022-08-11T10:09:01 Z | Sasha008 | Radio Towers (IOI22_towers) | C++17 | 4000 ms | 1480 KB |
#include<bits/stdc++.h> //#include "towers.h" #pragma GCC optimize ("O3") using namespace std; #define el "\n" #define se " " #define ll long long #define ld long double #define ff first #define ss second #define pb push_back const ll INF=1e18,ch=1e18; int a,b,c,d,n,COST,t,last,ab,ba,n1,n2,fl1,fl2,o1,o2,flag,flag1,flag2,g,m,m1,m2,i,j,lr,f,k,l,r,y,o,p,mx=-ch,mx1=-ch,mx2=-ch,q,q1,q2,q3,q4,mn=ch,mn1=ch,mn2=ch,f1,f2,f3,pos,ans,sum,sz=1,MOD=1e9+7,zero=0,a1,b1,c1,val,sum1,cur,res,ans1,res1,kk,kkk,cnt,cnt1,fl; int A[100005]; void init(int N, vector<int> H) { n=N; for(i=1;i<=n;i++) { A[i]=H[i-1]; if (i==1) continue; if (A[i-1]>A[i]) q=1; if (A[i-1]<A[i]) {j=i;} if (q==1&&A[i-1]<A[i]) flag=1; if (A[i]==A[i-1]) flag=1; } } int max_towers(int L, int R, int D) { int ans=1; if (flag==1) { l=L;r=R; l++;r++; a=A[l];q=-1; for(i=l+1;i<=r;i++) { if (q==-1) { if (A[i]<=a) {a=A[i];continue;} if (a<=A[i]-D) {q=A[i];continue;} } else { if (A[i]<=q-D) {q=-1;a=A[i];ans++;continue;} if (A[i]>q) q=A[i]; } } return ans; } else { l=L;r=R; l++;r++; if (l<=j&&j<=r&&A[l]<=A[j]-D&&A[r]<=A[j]-D) return 2; return 1; } } //int main() //{ // ios_base::sync_with_stdio(0); // cin.tie(0); // cout.tie(0); // cin>>n; // for(i=1;i<=n;i++) // { // cin>>A[i]; // } // cout<<max_towers(1, 5, 10); //} // ////7 ////10 20 60 40 50 30 70
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 380 ms | 976 KB | Output is correct |
2 | Correct | 667 ms | 1452 KB | Output is correct |
3 | Correct | 671 ms | 1360 KB | Output is correct |
4 | Correct | 612 ms | 1352 KB | Output is correct |
5 | Correct | 576 ms | 1452 KB | Output is correct |
6 | Correct | 713 ms | 1360 KB | Output is correct |
7 | Correct | 881 ms | 1452 KB | Output is correct |
8 | Correct | 0 ms | 208 KB | Output is correct |
9 | Correct | 1 ms | 308 KB | Output is correct |
10 | Correct | 1 ms | 208 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 0 ms | 208 KB | Output is correct |
3 | Correct | 1 ms | 208 KB | Output is correct |
4 | Correct | 1 ms | 208 KB | Output is correct |
5 | Correct | 1 ms | 208 KB | Output is correct |
6 | Correct | 1 ms | 208 KB | Output is correct |
7 | Correct | 1 ms | 208 KB | Output is correct |
8 | Correct | 0 ms | 208 KB | Output is correct |
9 | Correct | 1 ms | 208 KB | Output is correct |
10 | Correct | 0 ms | 208 KB | Output is correct |
11 | Correct | 1 ms | 208 KB | Output is correct |
12 | Correct | 0 ms | 208 KB | Output is correct |
13 | Correct | 1 ms | 208 KB | Output is correct |
14 | Correct | 0 ms | 208 KB | Output is correct |
15 | Correct | 1 ms | 208 KB | Output is correct |
16 | Correct | 1 ms | 208 KB | Output is correct |
17 | Correct | 1 ms | 208 KB | Output is correct |
18 | Correct | 1 ms | 208 KB | Output is correct |
19 | Correct | 1 ms | 208 KB | Output is correct |
20 | Correct | 1 ms | 208 KB | Output is correct |
21 | Correct | 0 ms | 208 KB | Output is correct |
22 | Correct | 1 ms | 208 KB | Output is correct |
23 | Correct | 1 ms | 208 KB | Output is correct |
24 | Correct | 1 ms | 208 KB | Output is correct |
25 | Correct | 1 ms | 208 KB | Output is correct |
26 | Correct | 1 ms | 208 KB | Output is correct |
27 | Correct | 0 ms | 208 KB | Output is correct |
28 | Correct | 1 ms | 208 KB | Output is correct |
29 | Correct | 0 ms | 208 KB | Output is correct |
30 | Correct | 0 ms | 208 KB | Output is correct |
31 | Correct | 1 ms | 208 KB | Output is correct |
32 | Correct | 0 ms | 208 KB | Output is correct |
33 | Correct | 1 ms | 208 KB | Output is correct |
34 | Correct | 1 ms | 208 KB | Output is correct |
35 | Correct | 1 ms | 208 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 0 ms | 208 KB | Output is correct |
3 | Correct | 1 ms | 208 KB | Output is correct |
4 | Correct | 1 ms | 208 KB | Output is correct |
5 | Correct | 1 ms | 208 KB | Output is correct |
6 | Correct | 1 ms | 208 KB | Output is correct |
7 | Correct | 1 ms | 208 KB | Output is correct |
8 | Correct | 0 ms | 208 KB | Output is correct |
9 | Correct | 1 ms | 208 KB | Output is correct |
10 | Correct | 0 ms | 208 KB | Output is correct |
11 | Correct | 1 ms | 208 KB | Output is correct |
12 | Correct | 0 ms | 208 KB | Output is correct |
13 | Correct | 1 ms | 208 KB | Output is correct |
14 | Correct | 0 ms | 208 KB | Output is correct |
15 | Correct | 1 ms | 208 KB | Output is correct |
16 | Correct | 1 ms | 208 KB | Output is correct |
17 | Correct | 1 ms | 208 KB | Output is correct |
18 | Correct | 1 ms | 208 KB | Output is correct |
19 | Correct | 1 ms | 208 KB | Output is correct |
20 | Correct | 1 ms | 208 KB | Output is correct |
21 | Correct | 0 ms | 208 KB | Output is correct |
22 | Correct | 1 ms | 208 KB | Output is correct |
23 | Correct | 1 ms | 208 KB | Output is correct |
24 | Correct | 1 ms | 208 KB | Output is correct |
25 | Correct | 1 ms | 208 KB | Output is correct |
26 | Correct | 1 ms | 208 KB | Output is correct |
27 | Correct | 0 ms | 208 KB | Output is correct |
28 | Correct | 1 ms | 208 KB | Output is correct |
29 | Correct | 0 ms | 208 KB | Output is correct |
30 | Correct | 0 ms | 208 KB | Output is correct |
31 | Correct | 1 ms | 208 KB | Output is correct |
32 | Correct | 0 ms | 208 KB | Output is correct |
33 | Correct | 1 ms | 208 KB | Output is correct |
34 | Correct | 1 ms | 208 KB | Output is correct |
35 | Correct | 1 ms | 208 KB | Output is correct |
36 | Correct | 8 ms | 1072 KB | Output is correct |
37 | Correct | 11 ms | 1440 KB | Output is correct |
38 | Correct | 12 ms | 1468 KB | Output is correct |
39 | Correct | 12 ms | 1456 KB | Output is correct |
40 | Correct | 23 ms | 1352 KB | Output is correct |
41 | Correct | 12 ms | 1452 KB | Output is correct |
42 | Correct | 10 ms | 1444 KB | Output is correct |
43 | Correct | 11 ms | 1452 KB | Output is correct |
44 | Correct | 16 ms | 1480 KB | Output is correct |
45 | Correct | 10 ms | 1452 KB | Output is correct |
46 | Correct | 11 ms | 1452 KB | Output is correct |
47 | Correct | 11 ms | 1448 KB | Output is correct |
48 | Correct | 10 ms | 1444 KB | Output is correct |
49 | Correct | 13 ms | 1432 KB | Output is correct |
50 | Correct | 10 ms | 1444 KB | Output is correct |
51 | Correct | 11 ms | 1360 KB | Output is correct |
52 | Correct | 11 ms | 1440 KB | Output is correct |
53 | Correct | 14 ms | 1444 KB | Output is correct |
54 | Correct | 12 ms | 1444 KB | Output is correct |
55 | Correct | 10 ms | 1448 KB | Output is correct |
56 | Correct | 11 ms | 1360 KB | Output is correct |
57 | Correct | 11 ms | 1360 KB | Output is correct |
58 | Correct | 12 ms | 1432 KB | Output is correct |
59 | Correct | 11 ms | 1448 KB | Output is correct |
60 | Correct | 13 ms | 1452 KB | Output is correct |
61 | Correct | 18 ms | 1388 KB | Output is correct |
62 | Correct | 12 ms | 1444 KB | Output is correct |
63 | Correct | 23 ms | 1452 KB | Output is correct |
64 | Correct | 11 ms | 1444 KB | Output is correct |
65 | Correct | 11 ms | 1444 KB | Output is correct |
66 | Correct | 11 ms | 1480 KB | Output is correct |
67 | Correct | 11 ms | 1360 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 4078 ms | 1448 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3587 ms | 464 KB | Output is correct |
2 | Execution timed out | 4062 ms | 1448 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 0 ms | 208 KB | Output is correct |
3 | Correct | 1 ms | 208 KB | Output is correct |
4 | Correct | 1 ms | 208 KB | Output is correct |
5 | Correct | 1 ms | 208 KB | Output is correct |
6 | Correct | 1 ms | 208 KB | Output is correct |
7 | Correct | 1 ms | 208 KB | Output is correct |
8 | Correct | 0 ms | 208 KB | Output is correct |
9 | Correct | 1 ms | 208 KB | Output is correct |
10 | Correct | 0 ms | 208 KB | Output is correct |
11 | Correct | 1 ms | 208 KB | Output is correct |
12 | Correct | 0 ms | 208 KB | Output is correct |
13 | Correct | 1 ms | 208 KB | Output is correct |
14 | Correct | 0 ms | 208 KB | Output is correct |
15 | Correct | 1 ms | 208 KB | Output is correct |
16 | Correct | 1 ms | 208 KB | Output is correct |
17 | Correct | 1 ms | 208 KB | Output is correct |
18 | Correct | 1 ms | 208 KB | Output is correct |
19 | Correct | 1 ms | 208 KB | Output is correct |
20 | Correct | 1 ms | 208 KB | Output is correct |
21 | Correct | 0 ms | 208 KB | Output is correct |
22 | Correct | 1 ms | 208 KB | Output is correct |
23 | Correct | 1 ms | 208 KB | Output is correct |
24 | Correct | 1 ms | 208 KB | Output is correct |
25 | Correct | 1 ms | 208 KB | Output is correct |
26 | Correct | 1 ms | 208 KB | Output is correct |
27 | Correct | 0 ms | 208 KB | Output is correct |
28 | Correct | 1 ms | 208 KB | Output is correct |
29 | Correct | 0 ms | 208 KB | Output is correct |
30 | Correct | 0 ms | 208 KB | Output is correct |
31 | Correct | 1 ms | 208 KB | Output is correct |
32 | Correct | 0 ms | 208 KB | Output is correct |
33 | Correct | 1 ms | 208 KB | Output is correct |
34 | Correct | 1 ms | 208 KB | Output is correct |
35 | Correct | 1 ms | 208 KB | Output is correct |
36 | Correct | 8 ms | 1072 KB | Output is correct |
37 | Correct | 11 ms | 1440 KB | Output is correct |
38 | Correct | 12 ms | 1468 KB | Output is correct |
39 | Correct | 12 ms | 1456 KB | Output is correct |
40 | Correct | 23 ms | 1352 KB | Output is correct |
41 | Correct | 12 ms | 1452 KB | Output is correct |
42 | Correct | 10 ms | 1444 KB | Output is correct |
43 | Correct | 11 ms | 1452 KB | Output is correct |
44 | Correct | 16 ms | 1480 KB | Output is correct |
45 | Correct | 10 ms | 1452 KB | Output is correct |
46 | Correct | 11 ms | 1452 KB | Output is correct |
47 | Correct | 11 ms | 1448 KB | Output is correct |
48 | Correct | 10 ms | 1444 KB | Output is correct |
49 | Correct | 13 ms | 1432 KB | Output is correct |
50 | Correct | 10 ms | 1444 KB | Output is correct |
51 | Correct | 11 ms | 1360 KB | Output is correct |
52 | Correct | 11 ms | 1440 KB | Output is correct |
53 | Correct | 14 ms | 1444 KB | Output is correct |
54 | Correct | 12 ms | 1444 KB | Output is correct |
55 | Correct | 10 ms | 1448 KB | Output is correct |
56 | Correct | 11 ms | 1360 KB | Output is correct |
57 | Correct | 11 ms | 1360 KB | Output is correct |
58 | Correct | 12 ms | 1432 KB | Output is correct |
59 | Correct | 11 ms | 1448 KB | Output is correct |
60 | Correct | 13 ms | 1452 KB | Output is correct |
61 | Correct | 18 ms | 1388 KB | Output is correct |
62 | Correct | 12 ms | 1444 KB | Output is correct |
63 | Correct | 23 ms | 1452 KB | Output is correct |
64 | Correct | 11 ms | 1444 KB | Output is correct |
65 | Correct | 11 ms | 1444 KB | Output is correct |
66 | Correct | 11 ms | 1480 KB | Output is correct |
67 | Correct | 11 ms | 1360 KB | Output is correct |
68 | Execution timed out | 4078 ms | 1448 KB | Time limit exceeded |
69 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 380 ms | 976 KB | Output is correct |
2 | Correct | 667 ms | 1452 KB | Output is correct |
3 | Correct | 671 ms | 1360 KB | Output is correct |
4 | Correct | 612 ms | 1352 KB | Output is correct |
5 | Correct | 576 ms | 1452 KB | Output is correct |
6 | Correct | 713 ms | 1360 KB | Output is correct |
7 | Correct | 881 ms | 1452 KB | Output is correct |
8 | Correct | 0 ms | 208 KB | Output is correct |
9 | Correct | 1 ms | 308 KB | Output is correct |
10 | Correct | 1 ms | 208 KB | Output is correct |
11 | Correct | 0 ms | 208 KB | Output is correct |
12 | Correct | 0 ms | 208 KB | Output is correct |
13 | Correct | 1 ms | 208 KB | Output is correct |
14 | Correct | 1 ms | 208 KB | Output is correct |
15 | Correct | 1 ms | 208 KB | Output is correct |
16 | Correct | 1 ms | 208 KB | Output is correct |
17 | Correct | 1 ms | 208 KB | Output is correct |
18 | Correct | 0 ms | 208 KB | Output is correct |
19 | Correct | 1 ms | 208 KB | Output is correct |
20 | Correct | 0 ms | 208 KB | Output is correct |
21 | Correct | 1 ms | 208 KB | Output is correct |
22 | Correct | 0 ms | 208 KB | Output is correct |
23 | Correct | 1 ms | 208 KB | Output is correct |
24 | Correct | 0 ms | 208 KB | Output is correct |
25 | Correct | 1 ms | 208 KB | Output is correct |
26 | Correct | 1 ms | 208 KB | Output is correct |
27 | Correct | 1 ms | 208 KB | Output is correct |
28 | Correct | 1 ms | 208 KB | Output is correct |
29 | Correct | 1 ms | 208 KB | Output is correct |
30 | Correct | 1 ms | 208 KB | Output is correct |
31 | Correct | 0 ms | 208 KB | Output is correct |
32 | Correct | 1 ms | 208 KB | Output is correct |
33 | Correct | 1 ms | 208 KB | Output is correct |
34 | Correct | 1 ms | 208 KB | Output is correct |
35 | Correct | 1 ms | 208 KB | Output is correct |
36 | Correct | 1 ms | 208 KB | Output is correct |
37 | Correct | 0 ms | 208 KB | Output is correct |
38 | Correct | 1 ms | 208 KB | Output is correct |
39 | Correct | 0 ms | 208 KB | Output is correct |
40 | Correct | 0 ms | 208 KB | Output is correct |
41 | Correct | 1 ms | 208 KB | Output is correct |
42 | Correct | 0 ms | 208 KB | Output is correct |
43 | Correct | 1 ms | 208 KB | Output is correct |
44 | Correct | 1 ms | 208 KB | Output is correct |
45 | Correct | 1 ms | 208 KB | Output is correct |
46 | Correct | 8 ms | 1072 KB | Output is correct |
47 | Correct | 11 ms | 1440 KB | Output is correct |
48 | Correct | 12 ms | 1468 KB | Output is correct |
49 | Correct | 12 ms | 1456 KB | Output is correct |
50 | Correct | 23 ms | 1352 KB | Output is correct |
51 | Correct | 12 ms | 1452 KB | Output is correct |
52 | Correct | 10 ms | 1444 KB | Output is correct |
53 | Correct | 11 ms | 1452 KB | Output is correct |
54 | Correct | 16 ms | 1480 KB | Output is correct |
55 | Correct | 10 ms | 1452 KB | Output is correct |
56 | Correct | 11 ms | 1452 KB | Output is correct |
57 | Correct | 11 ms | 1448 KB | Output is correct |
58 | Correct | 10 ms | 1444 KB | Output is correct |
59 | Correct | 13 ms | 1432 KB | Output is correct |
60 | Correct | 10 ms | 1444 KB | Output is correct |
61 | Correct | 11 ms | 1360 KB | Output is correct |
62 | Correct | 11 ms | 1440 KB | Output is correct |
63 | Correct | 14 ms | 1444 KB | Output is correct |
64 | Correct | 12 ms | 1444 KB | Output is correct |
65 | Correct | 10 ms | 1448 KB | Output is correct |
66 | Correct | 11 ms | 1360 KB | Output is correct |
67 | Correct | 11 ms | 1360 KB | Output is correct |
68 | Correct | 12 ms | 1432 KB | Output is correct |
69 | Correct | 11 ms | 1448 KB | Output is correct |
70 | Correct | 13 ms | 1452 KB | Output is correct |
71 | Correct | 18 ms | 1388 KB | Output is correct |
72 | Correct | 12 ms | 1444 KB | Output is correct |
73 | Correct | 23 ms | 1452 KB | Output is correct |
74 | Correct | 11 ms | 1444 KB | Output is correct |
75 | Correct | 11 ms | 1444 KB | Output is correct |
76 | Correct | 11 ms | 1480 KB | Output is correct |
77 | Correct | 11 ms | 1360 KB | Output is correct |
78 | Execution timed out | 4078 ms | 1448 KB | Time limit exceeded |
79 | Halted | 0 ms | 0 KB | - |