답안 #1066774

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1066774 2024-08-20T06:55:26 Z hasan2006 송신탑 (IOI22_towers) C++17
23 / 100
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

towers.cpp: In function 'void count_dp(int, int, int)':
towers.cpp:26:22: warning: unused variable 'j' [-Wunused-variable]
   26 |     int mx = 0 , i , j , x , y , s , f , m;
      |                      ^
towers.cpp:26:26: warning: unused variable 'x' [-Wunused-variable]
   26 |     int mx = 0 , i , j , x , y , s , f , m;
      |                          ^
towers.cpp:26:30: warning: unused variable 'y' [-Wunused-variable]
   26 |     int mx = 0 , i , j , x , y , s , f , m;
      |                              ^
towers.cpp:26:34: warning: unused variable 's' [-Wunused-variable]
   26 |     int mx = 0 , i , j , x , y , s , f , m;
      |                                  ^
towers.cpp:26:42: warning: unused variable 'm' [-Wunused-variable]
   26 |     int mx = 0 , i , j , x , y , s , f , m;
      |                                          ^
towers.cpp: In function 'int max_towers(int, int, int)':
towers.cpp:60:22: warning: unused variable 'j' [-Wunused-variable]
   60 |     int mx = 0 , i , j , x , y , s , f , m;
      |                      ^
towers.cpp:60:26: warning: unused variable 'x' [-Wunused-variable]
   60 |     int mx = 0 , i , j , x , y , s , f , m;
      |                          ^
towers.cpp:60:30: warning: unused variable 'y' [-Wunused-variable]
   60 |     int mx = 0 , i , j , x , y , s , f , m;
      |                              ^
towers.cpp:60:34: warning: unused variable 's' [-Wunused-variable]
   60 |     int mx = 0 , i , j , x , y , s , f , m;
      |                                  ^
towers.cpp:60:42: warning: unused variable 'm' [-Wunused-variable]
   60 |     int mx = 0 , i , j , x , y , s , f , m;
      |                                          ^
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4030 ms 3796 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -