Submission #790741

# Submission time Handle Problem Language Result Execution time Memory
790741 2023-07-23T07:21:52 Z penguinman Radio Towers (IOI22_towers) C++17
11 / 100
13 ms 3468 KB
#include "towers.h"

#include <bits/stdc++.h>

using std::vector;
using std::string;
using std::cin;
using std::cout;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using pii = std::pair<ll,ll>;
#define ln "\n"
#define rep(i,j,k) for(ll i=ll(j); i<ll(k); i++)
#define REP(i,j,k) for(ll i=ll(j); i<=ll(k); i++)
#define per(i,j,k) for(ll i=ll(j); i>=ll(k); i--)
#define all(a) a.begin(), a.end()
#define mp std::make_pair
constexpr ll inf = (1ll<<60);

ll N;
vi H;

void init(int n, std::vector<int> h) {
  N = n;
  H.resize(N);
  rep(i,0,N) H[i] = h[i];
  assert (N <= 2000);
}

int max_towers(int L, int R, int D) {
  vi h = H;
  ll ans = 0;
  REP(_,L,R){
    ll idx = std::min_element(H.begin()+L, H.begin()+R+1)-H.begin();
    bool flag = true;
    REP(j,idx+1,R){
      if(H[j] == inf){
        flag = false;
        break;
      }
      else if(H[j] == inf+1) continue;
      if(H[j] >= H[idx]+D) break;
    }
    per(j,idx-1,L){
      if(H[j] == inf){
        flag = false;
        break;
      }
      else if(H[j] == inf+1) continue;
      if(H[j] >= H[idx]+D) break;
    }
    if(flag){
      ans++;
      H[idx] = inf;
    }
    else H[idx] = inf+1;
  }
  H = h;
  return ans;
}
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 2256 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 3 ms 336 KB Output is correct
3 Correct 3 ms 336 KB Output is correct
4 Correct 2 ms 336 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 2 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 2 ms 336 KB Output is correct
14 Correct 2 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 5 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 9 ms 336 KB Output is correct
21 Correct 9 ms 340 KB Output is correct
22 Correct 9 ms 336 KB Output is correct
23 Correct 10 ms 340 KB Output is correct
24 Correct 9 ms 336 KB Output is correct
25 Correct 2 ms 208 KB Output is correct
26 Correct 9 ms 336 KB Output is correct
27 Correct 9 ms 336 KB Output is correct
28 Correct 9 ms 208 KB Output is correct
29 Correct 9 ms 344 KB Output is correct
30 Correct 9 ms 336 KB Output is correct
31 Correct 9 ms 336 KB Output is correct
32 Correct 13 ms 344 KB Output is correct
33 Correct 11 ms 336 KB Output is correct
34 Correct 12 ms 336 KB Output is correct
35 Correct 10 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 3 ms 336 KB Output is correct
3 Correct 3 ms 336 KB Output is correct
4 Correct 2 ms 336 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 2 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 2 ms 336 KB Output is correct
14 Correct 2 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 5 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 9 ms 336 KB Output is correct
21 Correct 9 ms 340 KB Output is correct
22 Correct 9 ms 336 KB Output is correct
23 Correct 10 ms 340 KB Output is correct
24 Correct 9 ms 336 KB Output is correct
25 Correct 2 ms 208 KB Output is correct
26 Correct 9 ms 336 KB Output is correct
27 Correct 9 ms 336 KB Output is correct
28 Correct 9 ms 208 KB Output is correct
29 Correct 9 ms 344 KB Output is correct
30 Correct 9 ms 336 KB Output is correct
31 Correct 9 ms 336 KB Output is correct
32 Correct 13 ms 344 KB Output is correct
33 Correct 11 ms 336 KB Output is correct
34 Correct 12 ms 336 KB Output is correct
35 Correct 10 ms 336 KB Output is correct
36 Runtime error 7 ms 2468 KB Execution killed with signal 6
37 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 13 ms 3468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 1184 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 3 ms 336 KB Output is correct
3 Correct 3 ms 336 KB Output is correct
4 Correct 2 ms 336 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 2 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 2 ms 336 KB Output is correct
14 Correct 2 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 5 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 9 ms 336 KB Output is correct
21 Correct 9 ms 340 KB Output is correct
22 Correct 9 ms 336 KB Output is correct
23 Correct 10 ms 340 KB Output is correct
24 Correct 9 ms 336 KB Output is correct
25 Correct 2 ms 208 KB Output is correct
26 Correct 9 ms 336 KB Output is correct
27 Correct 9 ms 336 KB Output is correct
28 Correct 9 ms 208 KB Output is correct
29 Correct 9 ms 344 KB Output is correct
30 Correct 9 ms 336 KB Output is correct
31 Correct 9 ms 336 KB Output is correct
32 Correct 13 ms 344 KB Output is correct
33 Correct 11 ms 336 KB Output is correct
34 Correct 12 ms 336 KB Output is correct
35 Correct 10 ms 336 KB Output is correct
36 Runtime error 7 ms 2468 KB Execution killed with signal 6
37 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 2256 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -