# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1066774 | 2024-08-20T06:55:26 Z | hasan2006 | Radio Towers (IOI22_towers) | C++17 | 4000 ms | 7392 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 , t[N] ; vector<int>a; void count_dp(int l , int r , int k){ int mx = 0 , i , j , x , y , s , f , m; d[r] = 1; f = r; set<int>st; int mn = a[r]; for(i = r - 1; i >= l; i--){ if(a[i] > mx){ d[i] = d[f]; if(a[i] - k >= mn) mx = max(mx , a[i] - k); mn = min(mn , a[i]); }else{ d[i] = d[f] + 1; mn= a[i]; mx = 0; f = i; } d[i] = max(d[i] , d[i + 1]); } } void init(int n , vector<int>a){ ::a = a; ::n = n; count_dp(0 , n - 1 , 1); } int max_towers(int l ,int r , int k){ // if(k == 1) // return d[r] - d[l] + 1; int mx = 0 , i , j , x , y , s , f , m; dp[r] = 1; f = r; set<int>st; int mn = a[r]; for(i = r - 1; i >= l; i--){ if(a[i] > mx){ dp[i] = dp[f]; if(a[i] - k >= mn) mx = max(mx , a[i] - k); mn = min(mn , a[i]); }else{ dp[i] = dp[f] + 1; mn= a[i]; mx = 0; f = i; } dp[i] = max(dp[i] , 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(0 , 6, 17)<<"\n"; }*/ // Author : حسن
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2826 ms | 4972 KB | Output is correct |
2 | Execution timed out | 4038 ms | 7376 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4440 KB | Output is correct |
2 | Correct | 1 ms | 4440 KB | Output is correct |
3 | Correct | 1 ms | 4440 KB | Output is correct |
4 | Correct | 1 ms | 4440 KB | Output is correct |
5 | Correct | 1 ms | 4440 KB | Output is correct |
6 | Correct | 1 ms | 4440 KB | Output is correct |
7 | Correct | 1 ms | 4440 KB | Output is correct |
8 | Correct | 1 ms | 4440 KB | Output is correct |
9 | Correct | 1 ms | 4440 KB | Output is correct |
10 | Correct | 1 ms | 4440 KB | Output is correct |
11 | Correct | 1 ms | 4440 KB | Output is correct |
12 | Correct | 1 ms | 4440 KB | Output is correct |
13 | Correct | 1 ms | 4440 KB | Output is correct |
14 | Correct | 1 ms | 4440 KB | Output is correct |
15 | Correct | 1 ms | 4440 KB | Output is correct |
16 | Correct | 1 ms | 4440 KB | Output is correct |
17 | Correct | 1 ms | 4440 KB | Output is correct |
18 | Correct | 1 ms | 4440 KB | Output is correct |
19 | Correct | 1 ms | 4440 KB | Output is correct |
20 | Correct | 1 ms | 4440 KB | Output is correct |
21 | Correct | 1 ms | 4440 KB | Output is correct |
22 | Correct | 1 ms | 4692 KB | Output is correct |
23 | Correct | 1 ms | 4440 KB | Output is correct |
24 | Correct | 1 ms | 4440 KB | Output is correct |
25 | Correct | 1 ms | 4440 KB | Output is correct |
26 | Correct | 1 ms | 4440 KB | Output is correct |
27 | Correct | 1 ms | 4440 KB | Output is correct |
28 | Correct | 1 ms | 4440 KB | Output is correct |
29 | Correct | 1 ms | 4440 KB | Output is correct |
30 | Correct | 1 ms | 4440 KB | Output is correct |
31 | Correct | 1 ms | 4440 KB | Output is correct |
32 | Correct | 1 ms | 4440 KB | Output is correct |
33 | Correct | 1 ms | 4440 KB | Output is correct |
34 | Correct | 1 ms | 4440 KB | Output is correct |
35 | Correct | 1 ms | 4440 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4440 KB | Output is correct |
2 | Correct | 1 ms | 4440 KB | Output is correct |
3 | Correct | 1 ms | 4440 KB | Output is correct |
4 | Correct | 1 ms | 4440 KB | Output is correct |
5 | Correct | 1 ms | 4440 KB | Output is correct |
6 | Correct | 1 ms | 4440 KB | Output is correct |
7 | Correct | 1 ms | 4440 KB | Output is correct |
8 | Correct | 1 ms | 4440 KB | Output is correct |
9 | Correct | 1 ms | 4440 KB | Output is correct |
10 | Correct | 1 ms | 4440 KB | Output is correct |
11 | Correct | 1 ms | 4440 KB | Output is correct |
12 | Correct | 1 ms | 4440 KB | Output is correct |
13 | Correct | 1 ms | 4440 KB | Output is correct |
14 | Correct | 1 ms | 4440 KB | Output is correct |
15 | Correct | 1 ms | 4440 KB | Output is correct |
16 | Correct | 1 ms | 4440 KB | Output is correct |
17 | Correct | 1 ms | 4440 KB | Output is correct |
18 | Correct | 1 ms | 4440 KB | Output is correct |
19 | Correct | 1 ms | 4440 KB | Output is correct |
20 | Correct | 1 ms | 4440 KB | Output is correct |
21 | Correct | 1 ms | 4440 KB | Output is correct |
22 | Correct | 1 ms | 4692 KB | Output is correct |
23 | Correct | 1 ms | 4440 KB | Output is correct |
24 | Correct | 1 ms | 4440 KB | Output is correct |
25 | Correct | 1 ms | 4440 KB | Output is correct |
26 | Correct | 1 ms | 4440 KB | Output is correct |
27 | Correct | 1 ms | 4440 KB | Output is correct |
28 | Correct | 1 ms | 4440 KB | Output is correct |
29 | Correct | 1 ms | 4440 KB | Output is correct |
30 | Correct | 1 ms | 4440 KB | Output is correct |
31 | Correct | 1 ms | 4440 KB | Output is correct |
32 | Correct | 1 ms | 4440 KB | Output is correct |
33 | Correct | 1 ms | 4440 KB | Output is correct |
34 | Correct | 1 ms | 4440 KB | Output is correct |
35 | Correct | 1 ms | 4440 KB | Output is correct |
36 | Correct | 7 ms | 4952 KB | Output is correct |
37 | Correct | 11 ms | 7216 KB | Output is correct |
38 | Correct | 16 ms | 7376 KB | Output is correct |
39 | Correct | 10 ms | 7376 KB | Output is correct |
40 | Correct | 9 ms | 7376 KB | Output is correct |
41 | Correct | 10 ms | 7220 KB | Output is correct |
42 | Correct | 9 ms | 7376 KB | Output is correct |
43 | Correct | 10 ms | 7360 KB | Output is correct |
44 | Correct | 14 ms | 7364 KB | Output is correct |
45 | Correct | 9 ms | 7376 KB | Output is correct |
46 | Correct | 10 ms | 7376 KB | Output is correct |
47 | Correct | 14 ms | 7376 KB | Output is correct |
48 | Correct | 10 ms | 7376 KB | Output is correct |
49 | Correct | 9 ms | 7376 KB | Output is correct |
50 | Correct | 9 ms | 7212 KB | Output is correct |
51 | Correct | 17 ms | 7376 KB | Output is correct |
52 | Correct | 11 ms | 7376 KB | Output is correct |
53 | Correct | 10 ms | 7392 KB | Output is correct |
54 | Correct | 9 ms | 7364 KB | Output is correct |
55 | Correct | 10 ms | 7376 KB | Output is correct |
56 | Correct | 16 ms | 7376 KB | Output is correct |
57 | Correct | 9 ms | 5596 KB | Output is correct |
58 | Correct | 10 ms | 3792 KB | Output is correct |
59 | Correct | 16 ms | 5720 KB | Output is correct |
60 | Correct | 9 ms | 3792 KB | Output is correct |
61 | Correct | 9 ms | 3792 KB | Output is correct |
62 | Correct | 10 ms | 5704 KB | Output is correct |
63 | Correct | 9 ms | 3792 KB | Output is correct |
64 | Correct | 9 ms | 3756 KB | Output is correct |
65 | Correct | 11 ms | 3792 KB | Output is correct |
66 | Correct | 18 ms | 3792 KB | Output is correct |
67 | Correct | 9 ms | 3776 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 4030 ms | 3796 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3509 ms | 900 KB | Output is correct |
2 | Execution timed out | 4057 ms | 7376 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4440 KB | Output is correct |
2 | Correct | 1 ms | 4440 KB | Output is correct |
3 | Correct | 1 ms | 4440 KB | Output is correct |
4 | Correct | 1 ms | 4440 KB | Output is correct |
5 | Correct | 1 ms | 4440 KB | Output is correct |
6 | Correct | 1 ms | 4440 KB | Output is correct |
7 | Correct | 1 ms | 4440 KB | Output is correct |
8 | Correct | 1 ms | 4440 KB | Output is correct |
9 | Correct | 1 ms | 4440 KB | Output is correct |
10 | Correct | 1 ms | 4440 KB | Output is correct |
11 | Correct | 1 ms | 4440 KB | Output is correct |
12 | Correct | 1 ms | 4440 KB | Output is correct |
13 | Correct | 1 ms | 4440 KB | Output is correct |
14 | Correct | 1 ms | 4440 KB | Output is correct |
15 | Correct | 1 ms | 4440 KB | Output is correct |
16 | Correct | 1 ms | 4440 KB | Output is correct |
17 | Correct | 1 ms | 4440 KB | Output is correct |
18 | Correct | 1 ms | 4440 KB | Output is correct |
19 | Correct | 1 ms | 4440 KB | Output is correct |
20 | Correct | 1 ms | 4440 KB | Output is correct |
21 | Correct | 1 ms | 4440 KB | Output is correct |
22 | Correct | 1 ms | 4692 KB | Output is correct |
23 | Correct | 1 ms | 4440 KB | Output is correct |
24 | Correct | 1 ms | 4440 KB | Output is correct |
25 | Correct | 1 ms | 4440 KB | Output is correct |
26 | Correct | 1 ms | 4440 KB | Output is correct |
27 | Correct | 1 ms | 4440 KB | Output is correct |
28 | Correct | 1 ms | 4440 KB | Output is correct |
29 | Correct | 1 ms | 4440 KB | Output is correct |
30 | Correct | 1 ms | 4440 KB | Output is correct |
31 | Correct | 1 ms | 4440 KB | Output is correct |
32 | Correct | 1 ms | 4440 KB | Output is correct |
33 | Correct | 1 ms | 4440 KB | Output is correct |
34 | Correct | 1 ms | 4440 KB | Output is correct |
35 | Correct | 1 ms | 4440 KB | Output is correct |
36 | Correct | 7 ms | 4952 KB | Output is correct |
37 | Correct | 11 ms | 7216 KB | Output is correct |
38 | Correct | 16 ms | 7376 KB | Output is correct |
39 | Correct | 10 ms | 7376 KB | Output is correct |
40 | Correct | 9 ms | 7376 KB | Output is correct |
41 | Correct | 10 ms | 7220 KB | Output is correct |
42 | Correct | 9 ms | 7376 KB | Output is correct |
43 | Correct | 10 ms | 7360 KB | Output is correct |
44 | Correct | 14 ms | 7364 KB | Output is correct |
45 | Correct | 9 ms | 7376 KB | Output is correct |
46 | Correct | 10 ms | 7376 KB | Output is correct |
47 | Correct | 14 ms | 7376 KB | Output is correct |
48 | Correct | 10 ms | 7376 KB | Output is correct |
49 | Correct | 9 ms | 7376 KB | Output is correct |
50 | Correct | 9 ms | 7212 KB | Output is correct |
51 | Correct | 17 ms | 7376 KB | Output is correct |
52 | Correct | 11 ms | 7376 KB | Output is correct |
53 | Correct | 10 ms | 7392 KB | Output is correct |
54 | Correct | 9 ms | 7364 KB | Output is correct |
55 | Correct | 10 ms | 7376 KB | Output is correct |
56 | Correct | 16 ms | 7376 KB | Output is correct |
57 | Correct | 9 ms | 5596 KB | Output is correct |
58 | Correct | 10 ms | 3792 KB | Output is correct |
59 | Correct | 16 ms | 5720 KB | Output is correct |
60 | Correct | 9 ms | 3792 KB | Output is correct |
61 | Correct | 9 ms | 3792 KB | Output is correct |
62 | Correct | 10 ms | 5704 KB | Output is correct |
63 | Correct | 9 ms | 3792 KB | Output is correct |
64 | Correct | 9 ms | 3756 KB | Output is correct |
65 | Correct | 11 ms | 3792 KB | Output is correct |
66 | Correct | 18 ms | 3792 KB | Output is correct |
67 | Correct | 9 ms | 3776 KB | Output is correct |
68 | Execution timed out | 4030 ms | 3796 KB | Time limit exceeded |
69 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2826 ms | 4972 KB | Output is correct |
2 | Execution timed out | 4038 ms | 7376 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |