답안 #625463

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
625463 2022-08-10T12:05:44 Z model_code 송신탑 (IOI22_towers) C++17
23 / 100
4000 ms 11332 KB
// time_limit/solution-ayaze-linear.cpp
#include "towers.h"

#include <bits/stdc++.h>
using namespace std;

int N;
vector<int> H;

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

int max_towers(int L, int R, int D) {
  set<pair<int, int>> height_idxs, idx_heights;
  set<int> taken;

  vector<pair<int, int>> vec;
  for (int i = L ; i <= R ; i++) {
    vec.push_back({H[i], i});
    height_idxs.insert({H[i], i});
    idx_heights.insert({i, H[i]});
  }

  sort(vec.begin(), vec.end());
  for (auto [h, i] : vec) {
    while (!height_idxs.empty() && height_idxs.begin()->first < h+D) {
      auto [height, idx] = *height_idxs.begin();
      height_idxs.erase({height, idx});
      idx_heights.erase({idx, height});
    }

    bool can_take = true;

    { // left side
      auto it = taken.lower_bound(i);
      if (it != taken.begin()) {
        it--;
        auto it2 = idx_heights.lower_bound({*it, -1});
        if (it2 == idx_heights.end() || it2->first > i) {
          can_take = false;
        }
      }
    }

    { // right side
      auto it = taken.upper_bound(i);
      if (it != taken.end()) {
        auto it2 = idx_heights.lower_bound({*it, -1});
        if (it2 == idx_heights.begin() || (--it2)->first < i) {
          can_take = false;
        }
      }
    }

    if (can_take) {
      taken.insert(i);
    }
  }

  return taken.size();
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4025 ms 6560 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 380 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 2 ms 336 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 3 ms 336 KB Output is correct
17 Correct 2 ms 372 KB Output is correct
18 Correct 2 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 3 ms 492 KB Output is correct
21 Correct 3 ms 512 KB Output is correct
22 Correct 4 ms 512 KB Output is correct
23 Correct 2 ms 464 KB Output is correct
24 Correct 2 ms 508 KB Output is correct
25 Correct 2 ms 336 KB Output is correct
26 Correct 3 ms 512 KB Output is correct
27 Correct 3 ms 464 KB Output is correct
28 Correct 2 ms 464 KB Output is correct
29 Correct 3 ms 496 KB Output is correct
30 Correct 3 ms 464 KB Output is correct
31 Correct 2 ms 464 KB Output is correct
32 Correct 2 ms 464 KB Output is correct
33 Correct 2 ms 464 KB Output is correct
34 Correct 2 ms 464 KB Output is correct
35 Correct 2 ms 464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 380 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 2 ms 336 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 3 ms 336 KB Output is correct
17 Correct 2 ms 372 KB Output is correct
18 Correct 2 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 3 ms 492 KB Output is correct
21 Correct 3 ms 512 KB Output is correct
22 Correct 4 ms 512 KB Output is correct
23 Correct 2 ms 464 KB Output is correct
24 Correct 2 ms 508 KB Output is correct
25 Correct 2 ms 336 KB Output is correct
26 Correct 3 ms 512 KB Output is correct
27 Correct 3 ms 464 KB Output is correct
28 Correct 2 ms 464 KB Output is correct
29 Correct 3 ms 496 KB Output is correct
30 Correct 3 ms 464 KB Output is correct
31 Correct 2 ms 464 KB Output is correct
32 Correct 2 ms 464 KB Output is correct
33 Correct 2 ms 464 KB Output is correct
34 Correct 2 ms 464 KB Output is correct
35 Correct 2 ms 464 KB Output is correct
36 Correct 58 ms 2700 KB Output is correct
37 Correct 76 ms 4656 KB Output is correct
38 Correct 43 ms 2368 KB Output is correct
39 Correct 60 ms 4344 KB Output is correct
40 Correct 34 ms 2360 KB Output is correct
41 Correct 232 ms 9432 KB Output is correct
42 Correct 17 ms 1484 KB Output is correct
43 Correct 56 ms 6228 KB Output is correct
44 Correct 20 ms 2400 KB Output is correct
45 Correct 13 ms 1456 KB Output is correct
46 Correct 19 ms 1448 KB Output is correct
47 Correct 74 ms 4648 KB Output is correct
48 Correct 58 ms 3244 KB Output is correct
49 Correct 23 ms 1880 KB Output is correct
50 Correct 38 ms 3228 KB Output is correct
51 Correct 48 ms 5020 KB Output is correct
52 Correct 295 ms 11156 KB Output is correct
53 Correct 280 ms 11196 KB Output is correct
54 Correct 274 ms 11236 KB Output is correct
55 Correct 80 ms 11200 KB Output is correct
56 Correct 91 ms 11176 KB Output is correct
57 Correct 213 ms 10784 KB Output is correct
58 Correct 261 ms 11148 KB Output is correct
59 Correct 266 ms 11160 KB Output is correct
60 Correct 382 ms 11332 KB Output is correct
61 Correct 340 ms 11152 KB Output is correct
62 Correct 307 ms 11156 KB Output is correct
63 Correct 338 ms 11140 KB Output is correct
64 Correct 106 ms 11152 KB Output is correct
65 Correct 100 ms 11156 KB Output is correct
66 Correct 102 ms 11252 KB Output is correct
67 Correct 79 ms 11184 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4024 ms 10240 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4030 ms 3224 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 380 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 2 ms 336 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 3 ms 336 KB Output is correct
17 Correct 2 ms 372 KB Output is correct
18 Correct 2 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 3 ms 492 KB Output is correct
21 Correct 3 ms 512 KB Output is correct
22 Correct 4 ms 512 KB Output is correct
23 Correct 2 ms 464 KB Output is correct
24 Correct 2 ms 508 KB Output is correct
25 Correct 2 ms 336 KB Output is correct
26 Correct 3 ms 512 KB Output is correct
27 Correct 3 ms 464 KB Output is correct
28 Correct 2 ms 464 KB Output is correct
29 Correct 3 ms 496 KB Output is correct
30 Correct 3 ms 464 KB Output is correct
31 Correct 2 ms 464 KB Output is correct
32 Correct 2 ms 464 KB Output is correct
33 Correct 2 ms 464 KB Output is correct
34 Correct 2 ms 464 KB Output is correct
35 Correct 2 ms 464 KB Output is correct
36 Correct 58 ms 2700 KB Output is correct
37 Correct 76 ms 4656 KB Output is correct
38 Correct 43 ms 2368 KB Output is correct
39 Correct 60 ms 4344 KB Output is correct
40 Correct 34 ms 2360 KB Output is correct
41 Correct 232 ms 9432 KB Output is correct
42 Correct 17 ms 1484 KB Output is correct
43 Correct 56 ms 6228 KB Output is correct
44 Correct 20 ms 2400 KB Output is correct
45 Correct 13 ms 1456 KB Output is correct
46 Correct 19 ms 1448 KB Output is correct
47 Correct 74 ms 4648 KB Output is correct
48 Correct 58 ms 3244 KB Output is correct
49 Correct 23 ms 1880 KB Output is correct
50 Correct 38 ms 3228 KB Output is correct
51 Correct 48 ms 5020 KB Output is correct
52 Correct 295 ms 11156 KB Output is correct
53 Correct 280 ms 11196 KB Output is correct
54 Correct 274 ms 11236 KB Output is correct
55 Correct 80 ms 11200 KB Output is correct
56 Correct 91 ms 11176 KB Output is correct
57 Correct 213 ms 10784 KB Output is correct
58 Correct 261 ms 11148 KB Output is correct
59 Correct 266 ms 11160 KB Output is correct
60 Correct 382 ms 11332 KB Output is correct
61 Correct 340 ms 11152 KB Output is correct
62 Correct 307 ms 11156 KB Output is correct
63 Correct 338 ms 11140 KB Output is correct
64 Correct 106 ms 11152 KB Output is correct
65 Correct 100 ms 11156 KB Output is correct
66 Correct 102 ms 11252 KB Output is correct
67 Correct 79 ms 11184 KB Output is correct
68 Execution timed out 4024 ms 10240 KB Time limit exceeded
69 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4025 ms 6560 KB Time limit exceeded
2 Halted 0 ms 0 KB -