Submission #1062082

# Submission time Handle Problem Language Result Execution time Memory
1062082 2024-08-16T18:37:02 Z MarwenElarbi Radio Towers (IOI22_towers) C++17
23 / 100
4000 ms 4684 KB
#include <bits/stdc++.h>
using namespace std;
#include "towers.h"
#define pb push_back
#define ll long long
#define fi first
#define se second
const int nax=1e5+5;
int n;
vector<int> tab,cor;
int segtree[nax*4][2];
void update(int pos,int l,int r,int idx,int value,int type){
  if(l==r){
    segtree[pos][type]=value;
    return;
  }
  int mid=(r+l)/2;
  if(idx<=mid) update(pos*2+1,l,mid,idx,value,type);
  else update(pos*2+2,mid+1,r,idx,value,type);
  segtree[pos][type]=max(segtree[pos*2+1][type],segtree[pos*2+2][type]);
}
int query(int pos,int l,int r,int left,int right,int type){
  if(l>r||l>right||r<left) return 0;
  if(l>=left&&r<=right) return segtree[pos][type];
  int mid=(r+l)/2;
  return max(query(pos*2+1,l,mid,left,right,type),query(pos*2+2,mid+1,r,left,right,type));
}
void init(int N, std::vector<int> H) {
  n=N;
  for (int i = 0; i < N; ++i)
  {
    tab.pb(H[i]);
  }
  cor=tab;
  sort(cor.begin(),cor.end());
}

int max_towers(int L, int R, int D){
  int dp[n],dp1[n];
  int ans=0;
  for (int i = L; i <= R; ++i)
  {
    int cur=upper_bound(cor.begin(),cor.end(),tab[i]-D)-cor.begin();
    int pos=lower_bound(cor.begin(),cor.end(),tab[i])-cor.begin();
    cur--;
    dp1[i]=query(0,0,n-1,0,cur,0);
    update(0,0,n-1,pos,dp1[i],1);
    cur=lower_bound(cor.begin(),cor.end(),tab[i]+D)-cor.begin();
    dp[i]=query(0,0,n-1,cur,n-1,1)+1;
    update(0,0,n-1,pos,dp[i],0);
    ans=max(ans,dp[i]);
  }
  return ans;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 4018 ms 2536 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 2 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 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 0 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 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 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 1 ms 344 KB Output is correct
21 Correct 2 ms 344 KB Output is correct
22 Correct 2 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 0 ms 344 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 2 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 2 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 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 0 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 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 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 1 ms 344 KB Output is correct
21 Correct 2 ms 344 KB Output is correct
22 Correct 2 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 0 ms 344 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 2 ms 344 KB Output is correct
36 Correct 24 ms 2772 KB Output is correct
37 Correct 32 ms 4680 KB Output is correct
38 Correct 25 ms 4424 KB Output is correct
39 Correct 28 ms 4680 KB Output is correct
40 Correct 26 ms 4424 KB Output is correct
41 Correct 67 ms 4564 KB Output is correct
42 Correct 18 ms 4420 KB Output is correct
43 Correct 38 ms 3400 KB Output is correct
44 Correct 16 ms 2632 KB Output is correct
45 Correct 11 ms 4424 KB Output is correct
46 Correct 10 ms 2376 KB Output is correct
47 Correct 47 ms 4560 KB Output is correct
48 Correct 39 ms 4424 KB Output is correct
49 Correct 22 ms 4532 KB Output is correct
50 Correct 28 ms 2892 KB Output is correct
51 Correct 28 ms 3256 KB Output is correct
52 Correct 94 ms 4572 KB Output is correct
53 Correct 97 ms 4424 KB Output is correct
54 Correct 94 ms 4424 KB Output is correct
55 Correct 63 ms 4416 KB Output is correct
56 Correct 61 ms 4676 KB Output is correct
57 Correct 72 ms 4436 KB Output is correct
58 Correct 77 ms 4572 KB Output is correct
59 Correct 85 ms 4680 KB Output is correct
60 Correct 97 ms 4556 KB Output is correct
61 Correct 92 ms 4680 KB Output is correct
62 Correct 78 ms 4680 KB Output is correct
63 Correct 88 ms 4424 KB Output is correct
64 Correct 43 ms 4680 KB Output is correct
65 Correct 43 ms 4416 KB Output is correct
66 Correct 48 ms 4680 KB Output is correct
67 Correct 44 ms 4416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4056 ms 4684 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4009 ms 3160 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 2 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 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 0 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 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 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 1 ms 344 KB Output is correct
21 Correct 2 ms 344 KB Output is correct
22 Correct 2 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 0 ms 344 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 2 ms 344 KB Output is correct
36 Correct 24 ms 2772 KB Output is correct
37 Correct 32 ms 4680 KB Output is correct
38 Correct 25 ms 4424 KB Output is correct
39 Correct 28 ms 4680 KB Output is correct
40 Correct 26 ms 4424 KB Output is correct
41 Correct 67 ms 4564 KB Output is correct
42 Correct 18 ms 4420 KB Output is correct
43 Correct 38 ms 3400 KB Output is correct
44 Correct 16 ms 2632 KB Output is correct
45 Correct 11 ms 4424 KB Output is correct
46 Correct 10 ms 2376 KB Output is correct
47 Correct 47 ms 4560 KB Output is correct
48 Correct 39 ms 4424 KB Output is correct
49 Correct 22 ms 4532 KB Output is correct
50 Correct 28 ms 2892 KB Output is correct
51 Correct 28 ms 3256 KB Output is correct
52 Correct 94 ms 4572 KB Output is correct
53 Correct 97 ms 4424 KB Output is correct
54 Correct 94 ms 4424 KB Output is correct
55 Correct 63 ms 4416 KB Output is correct
56 Correct 61 ms 4676 KB Output is correct
57 Correct 72 ms 4436 KB Output is correct
58 Correct 77 ms 4572 KB Output is correct
59 Correct 85 ms 4680 KB Output is correct
60 Correct 97 ms 4556 KB Output is correct
61 Correct 92 ms 4680 KB Output is correct
62 Correct 78 ms 4680 KB Output is correct
63 Correct 88 ms 4424 KB Output is correct
64 Correct 43 ms 4680 KB Output is correct
65 Correct 43 ms 4416 KB Output is correct
66 Correct 48 ms 4680 KB Output is correct
67 Correct 44 ms 4416 KB Output is correct
68 Execution timed out 4056 ms 4684 KB Time limit exceeded
69 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4018 ms 2536 KB Time limit exceeded
2 Halted 0 ms 0 KB -