Submission #626217

# Submission time Handle Problem Language Result Execution time Memory
626217 2022-08-11T10:01:21 Z Sasha008 Radio Towers (IOI22_towers) C++17
23 / 100
4000 ms 1580 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];
    }
}
int max_towers(int L, int R, int D)
{
    int ans=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;
}
//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

towers.cpp:13:104: warning: overflow in conversion from 'long long int' to 'int' changes value from '-1000000000000000000' to '1486618624' [-Woverflow]
   13 | 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;
      |                                                                                                        ^~~
towers.cpp:13:112: warning: overflow in conversion from 'long long int' to 'int' changes value from '-1000000000000000000' to '1486618624' [-Woverflow]
   13 | 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;
      |                                                                                                                ^~~
towers.cpp:13:120: warning: overflow in conversion from 'long long int' to 'int' changes value from '-1000000000000000000' to '1486618624' [-Woverflow]
   13 | 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;
      |                                                                                                                        ^~~
towers.cpp:13:141: warning: overflow in conversion from 'long long int' to 'int' changes value from '1000000000000000000' to '-1486618624' [-Woverflow]
   13 | 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;
      |                                                                                                                                             ^~
towers.cpp:13:148: warning: overflow in conversion from 'long long int' to 'int' changes value from '1000000000000000000' to '-1486618624' [-Woverflow]
   13 | 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;
      |                                                                                                                                                    ^~
towers.cpp:13:155: warning: overflow in conversion from 'long long int' to 'int' changes value from '1000000000000000000' to '-1486618624' [-Woverflow]
   13 | 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;
      |                                                                                                                                                           ^~
# Verdict Execution time Memory Grader output
1 Correct 1681 ms 920 KB Output is correct
2 Execution timed out 4006 ms 1428 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 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 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 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 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 1 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 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 0 ms 208 KB Output is correct
31 Correct 1 ms 312 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
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 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 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 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 1 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 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 0 ms 208 KB Output is correct
31 Correct 1 ms 312 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 15 ms 976 KB Output is correct
37 Correct 11 ms 1352 KB Output is correct
38 Correct 11 ms 1448 KB Output is correct
39 Correct 10 ms 1460 KB Output is correct
40 Correct 21 ms 1440 KB Output is correct
41 Correct 20 ms 1352 KB Output is correct
42 Correct 10 ms 1448 KB Output is correct
43 Correct 13 ms 1580 KB Output is correct
44 Correct 10 ms 1452 KB Output is correct
45 Correct 14 ms 1360 KB Output is correct
46 Correct 10 ms 1360 KB Output is correct
47 Correct 12 ms 1448 KB Output is correct
48 Correct 10 ms 1464 KB Output is correct
49 Correct 10 ms 1452 KB Output is correct
50 Correct 10 ms 1360 KB Output is correct
51 Correct 11 ms 1448 KB Output is correct
52 Correct 12 ms 1488 KB Output is correct
53 Correct 12 ms 1444 KB Output is correct
54 Correct 11 ms 1448 KB Output is correct
55 Correct 12 ms 1352 KB Output is correct
56 Correct 10 ms 1464 KB Output is correct
57 Correct 13 ms 1352 KB Output is correct
58 Correct 11 ms 1452 KB Output is correct
59 Correct 11 ms 1460 KB Output is correct
60 Correct 16 ms 1472 KB Output is correct
61 Correct 21 ms 1444 KB Output is correct
62 Correct 11 ms 1436 KB Output is correct
63 Correct 20 ms 1456 KB Output is correct
64 Correct 11 ms 1440 KB Output is correct
65 Correct 12 ms 1332 KB Output is correct
66 Correct 16 ms 1352 KB Output is correct
67 Correct 15 ms 1440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4010 ms 1440 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3747 ms 464 KB Output is correct
2 Execution timed out 4051 ms 1352 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 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 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 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 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 1 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 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 0 ms 208 KB Output is correct
31 Correct 1 ms 312 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 15 ms 976 KB Output is correct
37 Correct 11 ms 1352 KB Output is correct
38 Correct 11 ms 1448 KB Output is correct
39 Correct 10 ms 1460 KB Output is correct
40 Correct 21 ms 1440 KB Output is correct
41 Correct 20 ms 1352 KB Output is correct
42 Correct 10 ms 1448 KB Output is correct
43 Correct 13 ms 1580 KB Output is correct
44 Correct 10 ms 1452 KB Output is correct
45 Correct 14 ms 1360 KB Output is correct
46 Correct 10 ms 1360 KB Output is correct
47 Correct 12 ms 1448 KB Output is correct
48 Correct 10 ms 1464 KB Output is correct
49 Correct 10 ms 1452 KB Output is correct
50 Correct 10 ms 1360 KB Output is correct
51 Correct 11 ms 1448 KB Output is correct
52 Correct 12 ms 1488 KB Output is correct
53 Correct 12 ms 1444 KB Output is correct
54 Correct 11 ms 1448 KB Output is correct
55 Correct 12 ms 1352 KB Output is correct
56 Correct 10 ms 1464 KB Output is correct
57 Correct 13 ms 1352 KB Output is correct
58 Correct 11 ms 1452 KB Output is correct
59 Correct 11 ms 1460 KB Output is correct
60 Correct 16 ms 1472 KB Output is correct
61 Correct 21 ms 1444 KB Output is correct
62 Correct 11 ms 1436 KB Output is correct
63 Correct 20 ms 1456 KB Output is correct
64 Correct 11 ms 1440 KB Output is correct
65 Correct 12 ms 1332 KB Output is correct
66 Correct 16 ms 1352 KB Output is correct
67 Correct 15 ms 1440 KB Output is correct
68 Execution timed out 4010 ms 1440 KB Time limit exceeded
69 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1681 ms 920 KB Output is correct
2 Execution timed out 4006 ms 1428 KB Time limit exceeded
3 Halted 0 ms 0 KB -