Submission #1078857

# Submission time Handle Problem Language Result Execution time Memory
1078857 2024-08-28T07:15:31 Z mickey080929 Radio Towers (IOI22_towers) C++17
11 / 100
4000 ms 2000 KB
#include "towers.h"
#include <bits/stdc++.h>

using namespace std;

const int inf = 2e9 + 10;

int N;
vector<int> H;

void init(int _N, vector<int> _H) {
    N = _N;
    H = _H;
}

int max_towers(int L, int R, int D) {
    vector<int> id;
    for (int i=L; i<=R; i++) {
        id.push_back(i);
    }
    sort(id.begin(), id.end(), [&] (int &u, int &v) { return H[u] > H[v]; });
    int ans = 1;
    vector<int> pos = {L-1, R+1};
    for (int i=0; i<id.size(); i++) {
        vector<int> cur = pos;
        cur.push_back(id[i]);
        sort(cur.begin(), cur.end());
        int cnt = 0;
        for (int j=0; j+1<cur.size(); j++) {
            int lh, rh;
            if (cur[j] == L-1) lh = inf;
            else lh = H[cur[j]];
            if (cur[j+1] == R+1) rh = inf;
            else rh = H[cur[j+1]];
            for (int k=cur[j]+1; k<=cur[j+1]-1; k++) {
                if (H[k] <= min(lh, rh) - D) {
                    cnt ++;
                    break;
                }
            }
        }
        if (ans < cnt) {
            ans = cnt;
            pos = cur;
        }
    }
    return ans;
}

Compilation message

towers.cpp: In function 'int max_towers(int, int, int)':
towers.cpp:24:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for (int i=0; i<id.size(); i++) {
      |                   ~^~~~~~~~~~
towers.cpp:29:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         for (int j=0; j+1<cur.size(); j++) {
      |                       ~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 4026 ms 1192 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 4 ms 344 KB Output is correct
3 Correct 2 ms 344 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 2 ms 496 KB Output is correct
6 Correct 1 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 0 ms 344 KB Output is correct
10 Correct 1 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 1 ms 340 KB Output is correct
16 Correct 14 ms 344 KB Output is correct
17 Correct 2 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 17 ms 344 KB Output is correct
21 Correct 26 ms 344 KB Output is correct
22 Correct 26 ms 344 KB Output is correct
23 Correct 1 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 5 ms 344 KB Output is correct
27 Correct 12 ms 344 KB Output is correct
28 Correct 11 ms 528 KB Output is correct
29 Correct 13 ms 344 KB Output is correct
30 Correct 6 ms 344 KB Output is correct
31 Correct 8 ms 496 KB Output is correct
32 Correct 2 ms 460 KB Output is correct
33 Correct 2 ms 344 KB Output is correct
34 Correct 2 ms 344 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 4 ms 344 KB Output is correct
3 Correct 2 ms 344 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 2 ms 496 KB Output is correct
6 Correct 1 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 0 ms 344 KB Output is correct
10 Correct 1 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 1 ms 340 KB Output is correct
16 Correct 14 ms 344 KB Output is correct
17 Correct 2 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 17 ms 344 KB Output is correct
21 Correct 26 ms 344 KB Output is correct
22 Correct 26 ms 344 KB Output is correct
23 Correct 1 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 5 ms 344 KB Output is correct
27 Correct 12 ms 344 KB Output is correct
28 Correct 11 ms 528 KB Output is correct
29 Correct 13 ms 344 KB Output is correct
30 Correct 6 ms 344 KB Output is correct
31 Correct 8 ms 496 KB Output is correct
32 Correct 2 ms 460 KB Output is correct
33 Correct 2 ms 344 KB Output is correct
34 Correct 2 ms 344 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 2712 ms 1388 KB Output is correct
37 Correct 3433 ms 1488 KB Output is correct
38 Correct 1049 ms 1368 KB Output is correct
39 Correct 624 ms 1456 KB Output is correct
40 Correct 1581 ms 1420 KB Output is correct
41 Execution timed out 4051 ms 2000 KB Time limit exceeded
42 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4027 ms 1492 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4070 ms 876 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 4 ms 344 KB Output is correct
3 Correct 2 ms 344 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 2 ms 496 KB Output is correct
6 Correct 1 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 0 ms 344 KB Output is correct
10 Correct 1 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 1 ms 340 KB Output is correct
16 Correct 14 ms 344 KB Output is correct
17 Correct 2 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 17 ms 344 KB Output is correct
21 Correct 26 ms 344 KB Output is correct
22 Correct 26 ms 344 KB Output is correct
23 Correct 1 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 5 ms 344 KB Output is correct
27 Correct 12 ms 344 KB Output is correct
28 Correct 11 ms 528 KB Output is correct
29 Correct 13 ms 344 KB Output is correct
30 Correct 6 ms 344 KB Output is correct
31 Correct 8 ms 496 KB Output is correct
32 Correct 2 ms 460 KB Output is correct
33 Correct 2 ms 344 KB Output is correct
34 Correct 2 ms 344 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 2712 ms 1388 KB Output is correct
37 Correct 3433 ms 1488 KB Output is correct
38 Correct 1049 ms 1368 KB Output is correct
39 Correct 624 ms 1456 KB Output is correct
40 Correct 1581 ms 1420 KB Output is correct
41 Execution timed out 4051 ms 2000 KB Time limit exceeded
42 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4026 ms 1192 KB Time limit exceeded
2 Halted 0 ms 0 KB -