# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1053604 |
2024-08-11T14:15:00 Z |
Gray |
Radio Towers (IOI22_towers) |
C++17 |
|
4000 ms |
5084 KB |
#include "towers.h"
#include <algorithm>
#include <vector>
#define ll int
#define ff first
#define ss second
#define ln "\n"
using namespace std;
struct Fenwick{
vector<ll> tr;
ll n;
Fenwick(ll N){
n=N;
tr.resize(N+1);
}
void update(ll i, ll x){
for (; i<=n; i+=(-i&i)){
tr[i]=max(tr[i], x);
}
}
ll query(ll i){
ll ans=0;
for (; i; i-=(-i&i)) ans=max(ans, tr[i]);
return ans;
}
};
struct Fenwick2{
vector<ll> tr;
ll n;
Fenwick2(ll N){
n=N;
tr.resize(N+1);
}
void update(ll i, ll x){
for (; i; i-=(-i&i)){
tr[i]=max(tr[i], x);
}
}
ll query(ll i){
ll ans=0;
for (; i<=n; i+=(-i&i)) ans=max(ans, tr[i]);
return ans;
}
};
vector<int> a, sa;
ll getind(ll x){
return lower_bound(sa.begin(), sa.end(), x)-sa.begin();
}
ll n;
void init(int N, std::vector<int> H) {
a=H;
n=N;
}
// smallt ->
// bigt ->
int max_towers(int L, int R, int D) {
sa.clear();
sa=a;
for (auto ch:a){
sa.push_back(ch+D);
sa.push_back(max(0, ch-D));
}
sort(sa.begin(), sa.end());
sa.erase(unique(sa.begin(), sa.end()), sa.end());
Fenwick bigt(sa.size());
Fenwick2 smallt(sa.size());
ll mx=0;
for (ll i=L; i<=R; i++){
ll cur = smallt.query(getind(a[i]+D))+1;
mx=max(mx, cur);
if (a[i]>=D) smallt.update(getind(a[i]), bigt.query(getind(a[i]-D)));
bigt.update(getind(a[i]), cur);
}
return mx;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4059 ms |
3516 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
524 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 |
1 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 |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 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 |
2 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
1 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 |
0 ms |
344 KB |
Output is correct |
35 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
524 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 |
1 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 |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 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 |
2 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
1 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 |
0 ms |
344 KB |
Output is correct |
35 |
Correct |
1 ms |
344 KB |
Output is correct |
36 |
Correct |
23 ms |
3416 KB |
Output is correct |
37 |
Correct |
31 ms |
4280 KB |
Output is correct |
38 |
Correct |
28 ms |
4800 KB |
Output is correct |
39 |
Correct |
33 ms |
4280 KB |
Output is correct |
40 |
Correct |
30 ms |
4792 KB |
Output is correct |
41 |
Correct |
49 ms |
4576 KB |
Output is correct |
42 |
Correct |
30 ms |
5056 KB |
Output is correct |
43 |
Correct |
34 ms |
4828 KB |
Output is correct |
44 |
Correct |
23 ms |
4792 KB |
Output is correct |
45 |
Correct |
21 ms |
4288 KB |
Output is correct |
46 |
Correct |
19 ms |
4800 KB |
Output is correct |
47 |
Correct |
36 ms |
5084 KB |
Output is correct |
48 |
Correct |
31 ms |
5068 KB |
Output is correct |
49 |
Correct |
27 ms |
5056 KB |
Output is correct |
50 |
Correct |
19 ms |
5056 KB |
Output is correct |
51 |
Correct |
23 ms |
5056 KB |
Output is correct |
52 |
Correct |
60 ms |
5048 KB |
Output is correct |
53 |
Correct |
59 ms |
5056 KB |
Output is correct |
54 |
Correct |
59 ms |
5048 KB |
Output is correct |
55 |
Correct |
33 ms |
5056 KB |
Output is correct |
56 |
Correct |
36 ms |
5056 KB |
Output is correct |
57 |
Correct |
49 ms |
4320 KB |
Output is correct |
58 |
Correct |
56 ms |
4544 KB |
Output is correct |
59 |
Correct |
61 ms |
4924 KB |
Output is correct |
60 |
Correct |
72 ms |
5080 KB |
Output is correct |
61 |
Correct |
62 ms |
4800 KB |
Output is correct |
62 |
Correct |
57 ms |
4792 KB |
Output is correct |
63 |
Correct |
61 ms |
4800 KB |
Output is correct |
64 |
Correct |
30 ms |
4544 KB |
Output is correct |
65 |
Correct |
31 ms |
4544 KB |
Output is correct |
66 |
Correct |
35 ms |
4800 KB |
Output is correct |
67 |
Correct |
36 ms |
4536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4053 ms |
5068 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4016 ms |
1600 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
524 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 |
1 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 |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 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 |
2 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
1 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 |
0 ms |
344 KB |
Output is correct |
35 |
Correct |
1 ms |
344 KB |
Output is correct |
36 |
Correct |
23 ms |
3416 KB |
Output is correct |
37 |
Correct |
31 ms |
4280 KB |
Output is correct |
38 |
Correct |
28 ms |
4800 KB |
Output is correct |
39 |
Correct |
33 ms |
4280 KB |
Output is correct |
40 |
Correct |
30 ms |
4792 KB |
Output is correct |
41 |
Correct |
49 ms |
4576 KB |
Output is correct |
42 |
Correct |
30 ms |
5056 KB |
Output is correct |
43 |
Correct |
34 ms |
4828 KB |
Output is correct |
44 |
Correct |
23 ms |
4792 KB |
Output is correct |
45 |
Correct |
21 ms |
4288 KB |
Output is correct |
46 |
Correct |
19 ms |
4800 KB |
Output is correct |
47 |
Correct |
36 ms |
5084 KB |
Output is correct |
48 |
Correct |
31 ms |
5068 KB |
Output is correct |
49 |
Correct |
27 ms |
5056 KB |
Output is correct |
50 |
Correct |
19 ms |
5056 KB |
Output is correct |
51 |
Correct |
23 ms |
5056 KB |
Output is correct |
52 |
Correct |
60 ms |
5048 KB |
Output is correct |
53 |
Correct |
59 ms |
5056 KB |
Output is correct |
54 |
Correct |
59 ms |
5048 KB |
Output is correct |
55 |
Correct |
33 ms |
5056 KB |
Output is correct |
56 |
Correct |
36 ms |
5056 KB |
Output is correct |
57 |
Correct |
49 ms |
4320 KB |
Output is correct |
58 |
Correct |
56 ms |
4544 KB |
Output is correct |
59 |
Correct |
61 ms |
4924 KB |
Output is correct |
60 |
Correct |
72 ms |
5080 KB |
Output is correct |
61 |
Correct |
62 ms |
4800 KB |
Output is correct |
62 |
Correct |
57 ms |
4792 KB |
Output is correct |
63 |
Correct |
61 ms |
4800 KB |
Output is correct |
64 |
Correct |
30 ms |
4544 KB |
Output is correct |
65 |
Correct |
31 ms |
4544 KB |
Output is correct |
66 |
Correct |
35 ms |
4800 KB |
Output is correct |
67 |
Correct |
36 ms |
4536 KB |
Output is correct |
68 |
Execution timed out |
4053 ms |
5068 KB |
Time limit exceeded |
69 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4059 ms |
3516 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |