Submission #1066693

# Submission time Handle Problem Language Result Execution time Memory
1066693 2024-08-20T04:59:26 Z hasan2006 Radio Towers (IOI22_towers) C++17
11 / 100
4000 ms 1624 KB
#include <bits/stdc++.h>

using namespace std;

#define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define rall(s) s.rbegin(),s.rend()
#define all(s) s.begin(),s.end()
#define pb push_back
#define se second
#define fi first
#define ll long long
#define ld long double
#define YES cout<<"YES\n"
#define Yes cout<<"Yes\n"
#define yes cout<<"yes\n"
#define NO cout<<"NO\n"
#define No cout<<"No\n"
#define no cout<<"no\n"


const int N = 5e5 + 9 , mod = 1e9 + 7;
int b[N] , dp[N] , c[N] , d[N] , n ;
vector<int>a;


void init(int n , vector<int>a){
    ::a = a;
    ::n = n;
}


int max_towers(int l ,int r , int k){
    int mx = 1 , i , j , x , y , s , f , m;
    dp[r] = 1;
    for(i = r - 1; i >= l; i--){
        f = 0 , s = 0;
        for(j= i + 1; j <= r; j++){
            if(f - k >= a[j] && f - k >= a[i]){
                s = dp[j];
                break;
            }
            f = max(f , a[j]);

        }
        dp[i] = max(s + 1 , dp[i + 1]);
    }
    return dp[l];
}
/*
int main(){
    TL;

    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/
  //  init(7, {10, 20, 60, 40, 50, 30, 70});
  //  cout<<max_towers(1 , 5 , 10)<<"\n";
//}
// Author : حسن

Compilation message

towers.cpp: In function 'int max_towers(int, int, int)':
towers.cpp:33:9: warning: unused variable 'mx' [-Wunused-variable]
   33 |     int mx = 1 , i , j , x , y , s , f , m;
      |         ^~
towers.cpp:33:26: warning: unused variable 'x' [-Wunused-variable]
   33 |     int mx = 1 , i , j , x , y , s , f , m;
      |                          ^
towers.cpp:33:30: warning: unused variable 'y' [-Wunused-variable]
   33 |     int mx = 1 , i , j , x , y , s , f , m;
      |                              ^
towers.cpp:33:42: warning: unused variable 'm' [-Wunused-variable]
   33 |     int mx = 1 , i , j , x , y , s , f , m;
      |                                          ^
# Verdict Execution time Memory Grader output
1 Execution timed out 4065 ms 1192 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 2 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 2 ms 344 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 2 ms 344 KB Output is correct
29 Correct 2 ms 344 KB Output is correct
30 Correct 2 ms 344 KB Output is correct
31 Correct 2 ms 344 KB Output is correct
32 Correct 2 ms 344 KB Output is correct
33 Correct 2 ms 344 KB Output is correct
34 Correct 2 ms 472 KB Output is correct
35 Correct 2 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 2 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 2 ms 344 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 2 ms 344 KB Output is correct
29 Correct 2 ms 344 KB Output is correct
30 Correct 2 ms 344 KB Output is correct
31 Correct 2 ms 344 KB Output is correct
32 Correct 2 ms 344 KB Output is correct
33 Correct 2 ms 344 KB Output is correct
34 Correct 2 ms 472 KB Output is correct
35 Correct 2 ms 344 KB Output is correct
36 Correct 18 ms 1112 KB Output is correct
37 Correct 982 ms 1624 KB Output is correct
38 Correct 51 ms 1368 KB Output is correct
39 Correct 677 ms 1624 KB Output is correct
40 Correct 45 ms 1608 KB Output is correct
41 Correct 1621 ms 1624 KB Output is correct
42 Correct 9 ms 1368 KB Output is correct
43 Correct 1304 ms 1604 KB Output is correct
44 Correct 104 ms 1368 KB Output is correct
45 Correct 14 ms 1624 KB Output is correct
46 Correct 9 ms 1608 KB Output is correct
47 Correct 9 ms 1624 KB Output is correct
48 Correct 9 ms 1604 KB Output is correct
49 Correct 9 ms 1368 KB Output is correct
50 Correct 167 ms 1368 KB Output is correct
51 Correct 387 ms 1624 KB Output is correct
52 Correct 10 ms 1624 KB Output is correct
53 Correct 10 ms 1620 KB Output is correct
54 Correct 10 ms 1488 KB Output is correct
55 Correct 3408 ms 1604 KB Output is correct
56 Correct 1606 ms 1624 KB Output is correct
57 Execution timed out 4058 ms 1492 KB Time limit exceeded
58 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4026 ms 1608 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4043 ms 600 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 2 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 2 ms 344 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 2 ms 344 KB Output is correct
29 Correct 2 ms 344 KB Output is correct
30 Correct 2 ms 344 KB Output is correct
31 Correct 2 ms 344 KB Output is correct
32 Correct 2 ms 344 KB Output is correct
33 Correct 2 ms 344 KB Output is correct
34 Correct 2 ms 472 KB Output is correct
35 Correct 2 ms 344 KB Output is correct
36 Correct 18 ms 1112 KB Output is correct
37 Correct 982 ms 1624 KB Output is correct
38 Correct 51 ms 1368 KB Output is correct
39 Correct 677 ms 1624 KB Output is correct
40 Correct 45 ms 1608 KB Output is correct
41 Correct 1621 ms 1624 KB Output is correct
42 Correct 9 ms 1368 KB Output is correct
43 Correct 1304 ms 1604 KB Output is correct
44 Correct 104 ms 1368 KB Output is correct
45 Correct 14 ms 1624 KB Output is correct
46 Correct 9 ms 1608 KB Output is correct
47 Correct 9 ms 1624 KB Output is correct
48 Correct 9 ms 1604 KB Output is correct
49 Correct 9 ms 1368 KB Output is correct
50 Correct 167 ms 1368 KB Output is correct
51 Correct 387 ms 1624 KB Output is correct
52 Correct 10 ms 1624 KB Output is correct
53 Correct 10 ms 1620 KB Output is correct
54 Correct 10 ms 1488 KB Output is correct
55 Correct 3408 ms 1604 KB Output is correct
56 Correct 1606 ms 1624 KB Output is correct
57 Execution timed out 4058 ms 1492 KB Time limit exceeded
58 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4065 ms 1192 KB Time limit exceeded
2 Halted 0 ms 0 KB -