답안 #646119

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
646119 2022-09-28T17:59:32 Z NintsiChkhaidze 송신탑 (IOI22_towers) C++17
11 / 100
4000 ms 4828 KB
#include "towers.h"
#include <bits/stdc++.h>
#define pb push_back
#define left (h<<1),l ,(l+r)>>1
#define right ((h<<1)|1),((l+r)>>1) + 1,r
using namespace std;

const int N = 100005;
int n,a[N],l,r,d,L[N],R[N],t[4*N];
deque <int> dq;

void find(){
  /*
  while(dq.size()) dq.pop_front();
  
  for (int i =l; i <= r; i++){
    L[i] = l;
    while (dq.size() && a[dq.back()] < a[i] + d) dq.pop_back();
    if (dq.size()) L[i] = dq.back();
    dq.push_back(i);
  }

  while(dq.size()) dq.pop_front();
  for (int i = r; i >= l; i--){
    R[i] = r;
    while (dq.size() && a[dq.back()] < a[i] + d) dq.pop_back();
    if (dq.size()) R[i] = dq.back();
    dq.push_back(i);
  }*/

  for (int i = l; i <= r; i++){
    L[i] = l,R[i] = r;
    for (int j = i; j >= l; j--){
      if (a[j] >= a[i] + d) {
        L[i] = j;
        break;
      }
    }

    for (int j = i; j <= r; j++){
      if (a[j] >= a[i] + d){
        R[i] = j;
        break;
      }
    }
  }
  
}

void build(int h,int l,int r){
  if (l== r){
    t[h]=a[l];
    return;
  }
  build(left);
  build(right);
  t[h] = min(t[h*2],t[h*2+1]);
}

int getmin(int h,int l,int r,int L,int R){
  if (r < L || R < l) return 1e9;
  if (L <= l && r <= R) return t[h];
  return min(getmin(left,L,R),getmin(right,L,R));
}
void init(int N, vector<int> H) {
  n = N;
  for (int i = 1; i <= n; i++)
    a[i] = H[i-1];
  build(1,1,n);
}

int max_towers(int lf, int rg, int D) {
  l=lf+1,r=rg+1,d=D;
  find();
  vector <pair<int,int> > vec; vec.clear();
  for (int i = l; i <= r; i++)
    vec.pb({a[i],i});
  
  sort(vec.begin(),vec.end());
  int ans=0;
  for (auto [x,id]: vec){
    if (getmin(1,1,n, L[id], R[id]) < x) continue;
    ans++;
  }
  return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4066 ms 2536 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 1 ms 304 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 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 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 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 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 2 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 3 ms 336 KB Output is correct
27 Correct 2 ms 360 KB Output is correct
28 Correct 2 ms 336 KB Output is correct
29 Correct 3 ms 336 KB Output is correct
30 Correct 3 ms 336 KB Output is correct
31 Correct 3 ms 336 KB Output is correct
32 Correct 2 ms 336 KB Output is correct
33 Correct 3 ms 336 KB Output is correct
34 Correct 4 ms 336 KB Output is correct
35 Correct 2 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 1 ms 304 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 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 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 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 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 2 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 3 ms 336 KB Output is correct
27 Correct 2 ms 360 KB Output is correct
28 Correct 2 ms 336 KB Output is correct
29 Correct 3 ms 336 KB Output is correct
30 Correct 3 ms 336 KB Output is correct
31 Correct 3 ms 336 KB Output is correct
32 Correct 2 ms 336 KB Output is correct
33 Correct 3 ms 336 KB Output is correct
34 Correct 4 ms 336 KB Output is correct
35 Correct 2 ms 336 KB Output is correct
36 Correct 28 ms 1856 KB Output is correct
37 Correct 512 ms 3144 KB Output is correct
38 Correct 55 ms 2492 KB Output is correct
39 Correct 500 ms 2956 KB Output is correct
40 Correct 37 ms 2468 KB Output is correct
41 Correct 1845 ms 4268 KB Output is correct
42 Correct 13 ms 2376 KB Output is correct
43 Correct 954 ms 3556 KB Output is correct
44 Correct 104 ms 2512 KB Output is correct
45 Correct 16 ms 2472 KB Output is correct
46 Correct 19 ms 2476 KB Output is correct
47 Correct 22 ms 3120 KB Output is correct
48 Correct 18 ms 2632 KB Output is correct
49 Correct 14 ms 2452 KB Output is correct
50 Correct 170 ms 2628 KB Output is correct
51 Correct 297 ms 3136 KB Output is correct
52 Correct 48 ms 4328 KB Output is correct
53 Correct 42 ms 4416 KB Output is correct
54 Correct 41 ms 4416 KB Output is correct
55 Correct 3319 ms 4388 KB Output is correct
56 Correct 1539 ms 4384 KB Output is correct
57 Correct 3054 ms 4328 KB Output is correct
58 Correct 2307 ms 4536 KB Output is correct
59 Correct 1370 ms 4396 KB Output is correct
60 Correct 125 ms 4372 KB Output is correct
61 Correct 1311 ms 4416 KB Output is correct
62 Correct 2278 ms 4328 KB Output is correct
63 Correct 1292 ms 4536 KB Output is correct
64 Execution timed out 4035 ms 3056 KB Time limit exceeded
65 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4008 ms 4828 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4075 ms 1368 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 1 ms 304 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 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 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 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 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 2 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 3 ms 336 KB Output is correct
27 Correct 2 ms 360 KB Output is correct
28 Correct 2 ms 336 KB Output is correct
29 Correct 3 ms 336 KB Output is correct
30 Correct 3 ms 336 KB Output is correct
31 Correct 3 ms 336 KB Output is correct
32 Correct 2 ms 336 KB Output is correct
33 Correct 3 ms 336 KB Output is correct
34 Correct 4 ms 336 KB Output is correct
35 Correct 2 ms 336 KB Output is correct
36 Correct 28 ms 1856 KB Output is correct
37 Correct 512 ms 3144 KB Output is correct
38 Correct 55 ms 2492 KB Output is correct
39 Correct 500 ms 2956 KB Output is correct
40 Correct 37 ms 2468 KB Output is correct
41 Correct 1845 ms 4268 KB Output is correct
42 Correct 13 ms 2376 KB Output is correct
43 Correct 954 ms 3556 KB Output is correct
44 Correct 104 ms 2512 KB Output is correct
45 Correct 16 ms 2472 KB Output is correct
46 Correct 19 ms 2476 KB Output is correct
47 Correct 22 ms 3120 KB Output is correct
48 Correct 18 ms 2632 KB Output is correct
49 Correct 14 ms 2452 KB Output is correct
50 Correct 170 ms 2628 KB Output is correct
51 Correct 297 ms 3136 KB Output is correct
52 Correct 48 ms 4328 KB Output is correct
53 Correct 42 ms 4416 KB Output is correct
54 Correct 41 ms 4416 KB Output is correct
55 Correct 3319 ms 4388 KB Output is correct
56 Correct 1539 ms 4384 KB Output is correct
57 Correct 3054 ms 4328 KB Output is correct
58 Correct 2307 ms 4536 KB Output is correct
59 Correct 1370 ms 4396 KB Output is correct
60 Correct 125 ms 4372 KB Output is correct
61 Correct 1311 ms 4416 KB Output is correct
62 Correct 2278 ms 4328 KB Output is correct
63 Correct 1292 ms 4536 KB Output is correct
64 Execution timed out 4035 ms 3056 KB Time limit exceeded
65 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4066 ms 2536 KB Time limit exceeded
2 Halted 0 ms 0 KB -