# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
751864 | 2023-06-01T17:06:43 Z | HoriaHaivas | Intercastellar (JOI22_ho_t1) | C++14 | 103 ms | 13820 KB |
/* "TLE is like the wind, always by my side" - Yasuo - 2022 - */ #include <bits/stdc++.h> #define debug(x) cerr << #x << " " << x << "\n" #define debugs(x) cerr << #x << " " << x << " " #pragma GCC optimize("Ofast") #define int long long using namespace std; struct interval { int l; int r; int val; }; int desc(int x) { while (x%2==0) { x=x/2; } return x; } int lungime(int x) { int l=1; while (x%2==0) { x=x/2; l=l*2; } return l; } int v[200001]; interval span[200001]; int sp[200001]; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n,i,j,q,cnt,x,r,pas; cin >> n; for (i=1;i<=n;i++) { cin >> v[i]; } cnt=0; for (i=1;i<=n;i++) { cnt++; span[cnt].val=desc(v[i]); span[cnt].l=span[cnt-1].r+1; span[cnt].r=span[cnt].l+lungime(v[i])-1; } for (i=1;i<=cnt;i++) { sp[i]=sp[i-1]+span[i].r-span[i].l+1; } cin >> q; for (i=1;i<=q;i++) { cin >> x; r=0; pas=(1<<17); while (pas) { if (r+pas<=cnt && sp[r+pas]<x) r+=pas; pas=pas/2; } cout << span[r+1].val << "\n"; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 22 ms | 8480 KB | Output is correct |
4 | Correct | 37 ms | 3552 KB | Output is correct |
5 | Correct | 56 ms | 10184 KB | Output is correct |
6 | Correct | 33 ms | 8024 KB | Output is correct |
7 | Correct | 58 ms | 10160 KB | Output is correct |
8 | Correct | 55 ms | 10348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 328 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 344 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 22 ms | 8480 KB | Output is correct |
4 | Correct | 37 ms | 3552 KB | Output is correct |
5 | Correct | 56 ms | 10184 KB | Output is correct |
6 | Correct | 33 ms | 8024 KB | Output is correct |
7 | Correct | 58 ms | 10160 KB | Output is correct |
8 | Correct | 55 ms | 10348 KB | Output is correct |
9 | Correct | 1 ms | 328 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 0 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 344 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 28 ms | 3788 KB | Output is correct |
24 | Correct | 36 ms | 8460 KB | Output is correct |
25 | Correct | 77 ms | 13416 KB | Output is correct |
26 | Correct | 53 ms | 8524 KB | Output is correct |
27 | Correct | 47 ms | 8928 KB | Output is correct |
28 | Correct | 89 ms | 13796 KB | Output is correct |
29 | Correct | 103 ms | 13324 KB | Output is correct |
30 | Correct | 44 ms | 4360 KB | Output is correct |
31 | Correct | 96 ms | 13820 KB | Output is correct |