# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
705766 | 2023-03-05T07:10:24 Z | Abrar_Al_Samit | The Big Prize (IOI17_prize) | C++17 | 71 ms | 11344 KB |
#include<bits/stdc++.h> #include "prize.h" using namespace std; const int nax = 2e5 + 1; vector<vector<int>>mem(nax, vector<int>(2, -1)); vector<int>ASK(int i) { if(mem[i][0]==-1) { mem[i] = ask(i); } return mem[i]; } int find_best(int n) { int sq = min(n, 500); int mx = -1, id; int cnt = 0; auto up = [&] () { ++cnt; if(cnt>10000) assert(false); }; vector<int>prv; for(int i=0; i<sq; ++i) { up(); auto v = ASK(i); if(v[0]+v[1]==0) { return i; } if(v[0]+v[1]>mx) { mx = v[0] + v[1]; id = i; prv = v; if(mx*mx>n) break; } } while(id<n-1) { int to = min(n-1, id+sq); up(); auto cr = ASK(to); if(cr[0]==prv[0] && cr[1]==prv[1]) { id = to; continue; } int l = 0, r = to-id; while(l<r) { int mid = (l+r+1)/2; up(); cr = ASK(id+mid); if(cr[0]==prv[0] && cr[1]==prv[1]) { l = mid; } else { r = mid-1; } } id += l+1; while(id<n) { up(); cr = ASK(id); if(cr[0]+cr[1]==0) { return id; } if(cr[0]+cr[1]==mx) { prv = cr; break; } ++id; } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 11216 KB | Output is correct |
2 | Correct | 19 ms | 11268 KB | Output is correct |
3 | Correct | 13 ms | 11216 KB | Output is correct |
4 | Correct | 15 ms | 11216 KB | Output is correct |
5 | Correct | 17 ms | 11264 KB | Output is correct |
6 | Correct | 11 ms | 11180 KB | Output is correct |
7 | Correct | 16 ms | 11340 KB | Output is correct |
8 | Correct | 17 ms | 11268 KB | Output is correct |
9 | Correct | 17 ms | 11168 KB | Output is correct |
10 | Correct | 19 ms | 11184 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 18 ms | 11264 KB | Output is correct |
2 | Correct | 16 ms | 11264 KB | Output is correct |
3 | Correct | 20 ms | 11216 KB | Output is correct |
4 | Correct | 19 ms | 11260 KB | Output is correct |
5 | Correct | 13 ms | 11344 KB | Output is correct |
6 | Correct | 10 ms | 11216 KB | Output is correct |
7 | Correct | 13 ms | 11216 KB | Output is correct |
8 | Correct | 15 ms | 11216 KB | Output is correct |
9 | Correct | 14 ms | 11216 KB | Output is correct |
10 | Correct | 26 ms | 11224 KB | Output is correct |
11 | Correct | 20 ms | 11264 KB | Output is correct |
12 | Correct | 14 ms | 11260 KB | Output is correct |
13 | Correct | 19 ms | 11216 KB | Output is correct |
14 | Correct | 16 ms | 11216 KB | Output is correct |
15 | Correct | 20 ms | 11264 KB | Output is correct |
16 | Correct | 47 ms | 11260 KB | Output is correct |
17 | Correct | 11 ms | 11228 KB | Output is correct |
18 | Correct | 47 ms | 11216 KB | Output is correct |
19 | Correct | 12 ms | 11268 KB | Output is correct |
20 | Correct | 18 ms | 11216 KB | Output is correct |
21 | Correct | 26 ms | 11260 KB | Output is correct |
22 | Correct | 20 ms | 11244 KB | Output is correct |
23 | Correct | 16 ms | 11240 KB | Output is correct |
24 | Correct | 14 ms | 11216 KB | Output is correct |
25 | Correct | 37 ms | 11216 KB | Output is correct |
26 | Correct | 30 ms | 11216 KB | Output is correct |
27 | Correct | 16 ms | 11152 KB | Output is correct |
28 | Correct | 71 ms | 11216 KB | Output is correct |
29 | Correct | 45 ms | 11216 KB | Output is correct |
30 | Correct | 48 ms | 11216 KB | Output is correct |
31 | Correct | 12 ms | 11216 KB | Output is correct |
32 | Correct | 17 ms | 11272 KB | Output is correct |
33 | Correct | 10 ms | 11216 KB | Output is correct |
34 | Correct | 17 ms | 11248 KB | Output is correct |
35 | Correct | 14 ms | 11344 KB | Output is correct |
36 | Correct | 20 ms | 11216 KB | Output is correct |
37 | Correct | 20 ms | 11268 KB | Output is correct |
38 | Correct | 14 ms | 11264 KB | Output is correct |
39 | Correct | 19 ms | 11264 KB | Output is correct |
40 | Correct | 29 ms | 11264 KB | Output is correct |
41 | Correct | 41 ms | 11160 KB | Output is correct |
42 | Correct | 24 ms | 11344 KB | Output is correct |
43 | Correct | 33 ms | 11248 KB | Output is correct |
44 | Correct | 24 ms | 11216 KB | Output is correct |
45 | Correct | 23 ms | 11216 KB | Output is correct |
46 | Correct | 15 ms | 11216 KB | Output is correct |
47 | Correct | 20 ms | 11240 KB | Output is correct |
48 | Correct | 44 ms | 11244 KB | Output is correct |
49 | Correct | 12 ms | 11216 KB | Output is correct |
50 | Correct | 45 ms | 11344 KB | Output is correct |
51 | Correct | 30 ms | 11260 KB | Output is correct |
52 | Correct | 12 ms | 11344 KB | Output is correct |
53 | Correct | 20 ms | 11264 KB | Output is correct |
54 | Correct | 26 ms | 11264 KB | Output is correct |
55 | Correct | 11 ms | 11216 KB | Output is correct |
56 | Correct | 46 ms | 11276 KB | Output is correct |
57 | Correct | 45 ms | 11268 KB | Output is correct |
58 | Correct | 49 ms | 11264 KB | Output is correct |
59 | Correct | 32 ms | 11268 KB | Output is correct |
60 | Correct | 29 ms | 11216 KB | Output is correct |
61 | Correct | 17 ms | 11264 KB | Output is correct |
62 | Correct | 13 ms | 11216 KB | Output is correct |
63 | Correct | 19 ms | 11240 KB | Output is correct |
64 | Correct | 14 ms | 11216 KB | Output is correct |
65 | Correct | 18 ms | 11260 KB | Output is correct |
66 | Correct | 25 ms | 11200 KB | Output is correct |
67 | Correct | 18 ms | 11164 KB | Output is correct |
68 | Correct | 15 ms | 11216 KB | Output is correct |
69 | Correct | 19 ms | 11216 KB | Output is correct |
70 | Correct | 14 ms | 11344 KB | Output is correct |
71 | Correct | 62 ms | 11216 KB | Output is correct |
72 | Correct | 26 ms | 11216 KB | Output is correct |
73 | Correct | 61 ms | 11260 KB | Output is correct |
74 | Correct | 59 ms | 11216 KB | Output is correct |
75 | Correct | 17 ms | 11216 KB | Output is correct |
76 | Correct | 37 ms | 11216 KB | Output is correct |
77 | Correct | 54 ms | 11160 KB | Output is correct |
78 | Correct | 20 ms | 11216 KB | Output is correct |
79 | Correct | 39 ms | 11224 KB | Output is correct |
80 | Correct | 63 ms | 11216 KB | Output is correct |
81 | Correct | 45 ms | 11264 KB | Output is correct |
82 | Correct | 35 ms | 11216 KB | Output is correct |
83 | Correct | 19 ms | 11256 KB | Output is correct |
84 | Correct | 37 ms | 11216 KB | Output is correct |
85 | Correct | 44 ms | 11216 KB | Output is correct |
86 | Correct | 21 ms | 11252 KB | Output is correct |
87 | Correct | 19 ms | 11272 KB | Output is correct |
88 | Correct | 23 ms | 11264 KB | Output is correct |
89 | Correct | 19 ms | 11216 KB | Output is correct |
90 | Correct | 16 ms | 11216 KB | Output is correct |
91 | Correct | 17 ms | 11228 KB | Output is correct |
92 | Correct | 17 ms | 11264 KB | Output is correct |
93 | Correct | 20 ms | 11160 KB | Output is correct |
94 | Correct | 20 ms | 11168 KB | Output is correct |
95 | Correct | 20 ms | 11228 KB | Output is correct |
96 | Correct | 19 ms | 11216 KB | Output is correct |
97 | Correct | 17 ms | 11172 KB | Output is correct |