Submission #1081905

# Submission time Handle Problem Language Result Execution time Memory
1081905 2024-08-30T12:45:56 Z farica Radio Towers (IOI22_towers) C++17
15 / 100
4000 ms 1748 KB
#include "towers.h"

#include <bits/stdc++.h>

using namespace std;

int n,sub1=1,idx=0;
vector<int> h;

void init(int N, vector<int> H) {
    h.clear();
    sub1 = 1;
    n = N;
    for(auto x : H)
        h.push_back(x);
    int ok=1;
    for(int i=0; i<H.size()-1; i++) {
        if(ok and H[i] > H[i+1]) {
            ok=0;
            idx = i;
        }
        if(!ok and H[i] < H[i+1])
            sub1=0;
    }
}

int max_towers(int L, int R, int D) {
    if(sub1) {
        if(idx > L and idx < R and (h[L]+D) <= h[idx] and (h[R]+D) <= h[idx])
            return 2;
        else
            return 1;
    }
    vector<int> dp(n+1,1);
    int ans=0;
    for(int i=L+2; i<=R; i++) {
        int maksInd=0;
        for(int j=i-1; j>=L; --j) {
            if(maksInd >= h[i]+D && maksInd >= h[j]+D) dp[i] = max(dp[i], dp[j] + 1);
            maksInd = max(maksInd, h[j]);
        }
        ans = max(ans,dp[i]);
    }
    return ans;
}

Compilation message

towers.cpp: In function 'void init(int, std::vector<int>)':
towers.cpp:17:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(int i=0; i<H.size()-1; i++) {
      |                  ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 286 ms 1236 KB Output is correct
2 Correct 638 ms 1748 KB Output is correct
3 Correct 634 ms 1748 KB Output is correct
4 Correct 593 ms 1748 KB Output is correct
5 Correct 641 ms 1748 KB Output is correct
6 Correct 570 ms 1748 KB Output is correct
7 Correct 622 ms 1748 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
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 424 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 2 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 3 ms 344 KB Output is correct
21 Correct 3 ms 344 KB Output is correct
22 Correct 3 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 2 ms 456 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 2 ms 344 KB Output is correct
27 Correct 2 ms 344 KB Output is correct
28 Correct 2 ms 344 KB Output is correct
29 Correct 2 ms 460 KB Output is correct
30 Correct 2 ms 344 KB Output is correct
31 Correct 2 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 2 ms 344 KB Output is correct
35 Correct 3 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 424 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 2 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 3 ms 344 KB Output is correct
21 Correct 3 ms 344 KB Output is correct
22 Correct 3 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 2 ms 456 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 2 ms 344 KB Output is correct
27 Correct 2 ms 344 KB Output is correct
28 Correct 2 ms 344 KB Output is correct
29 Correct 2 ms 460 KB Output is correct
30 Correct 2 ms 344 KB Output is correct
31 Correct 2 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 2 ms 344 KB Output is correct
35 Correct 3 ms 344 KB Output is correct
36 Correct 250 ms 1236 KB Output is correct
37 Correct 724 ms 1748 KB Output is correct
38 Correct 173 ms 1748 KB Output is correct
39 Correct 376 ms 1748 KB Output is correct
40 Correct 112 ms 1724 KB Output is correct
41 Correct 2933 ms 1748 KB Output is correct
42 Correct 18 ms 1748 KB Output is correct
43 Correct 9 ms 1716 KB Output is correct
44 Correct 9 ms 1744 KB Output is correct
45 Correct 11 ms 1748 KB Output is correct
46 Correct 12 ms 1716 KB Output is correct
47 Correct 635 ms 1748 KB Output is correct
48 Correct 233 ms 1720 KB Output is correct
49 Correct 40 ms 1744 KB Output is correct
50 Correct 9 ms 1748 KB Output is correct
51 Correct 530 ms 1724 KB Output is correct
52 Execution timed out 4051 ms 1748 KB Time limit exceeded
53 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4037 ms 1748 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4034 ms 600 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 424 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 2 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 3 ms 344 KB Output is correct
21 Correct 3 ms 344 KB Output is correct
22 Correct 3 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 2 ms 456 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 2 ms 344 KB Output is correct
27 Correct 2 ms 344 KB Output is correct
28 Correct 2 ms 344 KB Output is correct
29 Correct 2 ms 460 KB Output is correct
30 Correct 2 ms 344 KB Output is correct
31 Correct 2 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 2 ms 344 KB Output is correct
35 Correct 3 ms 344 KB Output is correct
36 Correct 250 ms 1236 KB Output is correct
37 Correct 724 ms 1748 KB Output is correct
38 Correct 173 ms 1748 KB Output is correct
39 Correct 376 ms 1748 KB Output is correct
40 Correct 112 ms 1724 KB Output is correct
41 Correct 2933 ms 1748 KB Output is correct
42 Correct 18 ms 1748 KB Output is correct
43 Correct 9 ms 1716 KB Output is correct
44 Correct 9 ms 1744 KB Output is correct
45 Correct 11 ms 1748 KB Output is correct
46 Correct 12 ms 1716 KB Output is correct
47 Correct 635 ms 1748 KB Output is correct
48 Correct 233 ms 1720 KB Output is correct
49 Correct 40 ms 1744 KB Output is correct
50 Correct 9 ms 1748 KB Output is correct
51 Correct 530 ms 1724 KB Output is correct
52 Execution timed out 4051 ms 1748 KB Time limit exceeded
53 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 286 ms 1236 KB Output is correct
2 Correct 638 ms 1748 KB Output is correct
3 Correct 634 ms 1748 KB Output is correct
4 Correct 593 ms 1748 KB Output is correct
5 Correct 641 ms 1748 KB Output is correct
6 Correct 570 ms 1748 KB Output is correct
7 Correct 622 ms 1748 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 1 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 1 ms 424 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 1 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 1 ms 596 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 0 ms 344 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 3 ms 344 KB Output is correct
31 Correct 3 ms 344 KB Output is correct
32 Correct 3 ms 344 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 2 ms 456 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 2 ms 344 KB Output is correct
37 Correct 2 ms 344 KB Output is correct
38 Correct 2 ms 344 KB Output is correct
39 Correct 2 ms 460 KB Output is correct
40 Correct 2 ms 344 KB Output is correct
41 Correct 2 ms 344 KB Output is correct
42 Correct 0 ms 344 KB Output is correct
43 Correct 0 ms 344 KB Output is correct
44 Correct 2 ms 344 KB Output is correct
45 Correct 3 ms 344 KB Output is correct
46 Correct 250 ms 1236 KB Output is correct
47 Correct 724 ms 1748 KB Output is correct
48 Correct 173 ms 1748 KB Output is correct
49 Correct 376 ms 1748 KB Output is correct
50 Correct 112 ms 1724 KB Output is correct
51 Correct 2933 ms 1748 KB Output is correct
52 Correct 18 ms 1748 KB Output is correct
53 Correct 9 ms 1716 KB Output is correct
54 Correct 9 ms 1744 KB Output is correct
55 Correct 11 ms 1748 KB Output is correct
56 Correct 12 ms 1716 KB Output is correct
57 Correct 635 ms 1748 KB Output is correct
58 Correct 233 ms 1720 KB Output is correct
59 Correct 40 ms 1744 KB Output is correct
60 Correct 9 ms 1748 KB Output is correct
61 Correct 530 ms 1724 KB Output is correct
62 Execution timed out 4051 ms 1748 KB Time limit exceeded
63 Halted 0 ms 0 KB -