#include "prize.h"
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout << "[" << #__VA_ARGS__ << ": " << __VA_ARGS__ << "]\n"
#define rd() abs((int)rng())
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 2e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
/*vector<int> ask(int i)
{
cout << "? " << i << endl;
vector<int>a(2);
cin >> a[0] >> a[1];
return a;
}*/
int find_best(int n)
{
vector<int>a;
if(n < 5000)
{
for(int i = 0; i < n; i++)
{
a = ask(i);
if(a[0] == 0 && a[1] == 0)
return i;
}
}
int mx = 0;
for(int i = 0; i < 500; i++)
{
a = ask(i);
mx = max(mx, a[0] + a[1]);
}
int i = 0;
while(i < n)
{
a = ask(i);
if(a[0] + a[1] == 0)
return i;
if(a[0] + a[1] == mx)
{
vector<int>b = a;
int l = i + 1, r = n - 1;
while(l < r)
{
int mid = (l + r + 1) / 2;
a = ask(mid);
if(b == a)
l = mid;
else
r = mid - 1;
}
a = ask(l);
if(a[0] + a[1] == 0)
return l;
i = l + 1;
}
else
i++;
}
}
Compilation message
prize.cpp: In function 'int find_best(int)':
prize.cpp:69:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
248 KB |
Output is correct |
2 |
Correct |
7 ms |
248 KB |
Output is correct |
3 |
Correct |
8 ms |
248 KB |
Output is correct |
4 |
Correct |
6 ms |
376 KB |
Output is correct |
5 |
Correct |
4 ms |
504 KB |
Output is correct |
6 |
Correct |
4 ms |
504 KB |
Output is correct |
7 |
Correct |
5 ms |
504 KB |
Output is correct |
8 |
Correct |
5 ms |
380 KB |
Output is correct |
9 |
Correct |
8 ms |
376 KB |
Output is correct |
10 |
Correct |
8 ms |
248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
376 KB |
Output is correct |
2 |
Correct |
7 ms |
376 KB |
Output is correct |
3 |
Correct |
8 ms |
376 KB |
Output is correct |
4 |
Correct |
8 ms |
248 KB |
Output is correct |
5 |
Correct |
6 ms |
248 KB |
Output is correct |
6 |
Correct |
6 ms |
312 KB |
Output is correct |
7 |
Correct |
7 ms |
380 KB |
Output is correct |
8 |
Correct |
4 ms |
392 KB |
Output is correct |
9 |
Correct |
8 ms |
248 KB |
Output is correct |
10 |
Correct |
4 ms |
248 KB |
Output is correct |
11 |
Correct |
6 ms |
396 KB |
Output is correct |
12 |
Correct |
8 ms |
248 KB |
Output is correct |
13 |
Correct |
13 ms |
312 KB |
Output is correct |
14 |
Correct |
12 ms |
248 KB |
Output is correct |
15 |
Correct |
11 ms |
376 KB |
Output is correct |
16 |
Partially correct |
76 ms |
248 KB |
Partially correct - number of queries: 8220 |
17 |
Correct |
5 ms |
404 KB |
Output is correct |
18 |
Partially correct |
49 ms |
376 KB |
Partially correct - number of queries: 9583 |
19 |
Correct |
4 ms |
420 KB |
Output is correct |
20 |
Correct |
16 ms |
400 KB |
Output is correct |
21 |
Correct |
41 ms |
248 KB |
Output is correct |
22 |
Correct |
13 ms |
376 KB |
Output is correct |
23 |
Correct |
6 ms |
376 KB |
Output is correct |
24 |
Correct |
5 ms |
400 KB |
Output is correct |
25 |
Partially correct |
55 ms |
376 KB |
Partially correct - number of queries: 5633 |
26 |
Partially correct |
55 ms |
248 KB |
Partially correct - number of queries: 5539 |
27 |
Correct |
7 ms |
376 KB |
Output is correct |
28 |
Partially correct |
74 ms |
308 KB |
Partially correct - number of queries: 9108 |
29 |
Partially correct |
80 ms |
248 KB |
Partially correct - number of queries: 7032 |
30 |
Partially correct |
98 ms |
248 KB |
Partially correct - number of queries: 9522 |
31 |
Correct |
6 ms |
248 KB |
Output is correct |
32 |
Correct |
11 ms |
248 KB |
Output is correct |
33 |
Correct |
2 ms |
248 KB |
Output is correct |
34 |
Correct |
37 ms |
312 KB |
Output is correct |
35 |
Correct |
10 ms |
248 KB |
Output is correct |
36 |
Correct |
31 ms |
248 KB |
Output is correct |
37 |
Correct |
5 ms |
376 KB |
Output is correct |
38 |
Correct |
6 ms |
376 KB |
Output is correct |
39 |
Correct |
42 ms |
248 KB |
Output is correct |
40 |
Partially correct |
79 ms |
248 KB |
Partially correct - number of queries: 8214 |
41 |
Partially correct |
58 ms |
248 KB |
Partially correct - number of queries: 5912 |
42 |
Partially correct |
71 ms |
252 KB |
Partially correct - number of queries: 5912 |
43 |
Partially correct |
55 ms |
376 KB |
Partially correct - number of queries: 5380 |
44 |
Correct |
39 ms |
248 KB |
Output is correct |
45 |
Correct |
36 ms |
396 KB |
Output is correct |
46 |
Correct |
7 ms |
248 KB |
Output is correct |
47 |
Correct |
41 ms |
376 KB |
Output is correct |
48 |
Partially correct |
72 ms |
376 KB |
Partially correct - number of queries: 7208 |
49 |
Correct |
17 ms |
248 KB |
Output is correct |
50 |
Partially correct |
61 ms |
376 KB |
Partially correct - number of queries: 9594 |
51 |
Correct |
43 ms |
248 KB |
Output is correct |
52 |
Correct |
10 ms |
248 KB |
Output is correct |
53 |
Correct |
6 ms |
376 KB |
Output is correct |
54 |
Correct |
23 ms |
308 KB |
Output is correct |
55 |
Correct |
7 ms |
308 KB |
Output is correct |
56 |
Partially correct |
94 ms |
248 KB |
Partially correct - number of queries: 9594 |
57 |
Partially correct |
73 ms |
392 KB |
Partially correct - number of queries: 7111 |
58 |
Partially correct |
80 ms |
248 KB |
Partially correct - number of queries: 7224 |
59 |
Partially correct |
31 ms |
376 KB |
Partially correct - number of queries: 5912 |
60 |
Partially correct |
53 ms |
392 KB |
Partially correct - number of queries: 5529 |
61 |
Correct |
5 ms |
312 KB |
Output is correct |
62 |
Correct |
5 ms |
308 KB |
Output is correct |
63 |
Correct |
8 ms |
376 KB |
Output is correct |
64 |
Correct |
5 ms |
396 KB |
Output is correct |
65 |
Correct |
8 ms |
248 KB |
Output is correct |
66 |
Correct |
12 ms |
376 KB |
Output is correct |
67 |
Correct |
4 ms |
308 KB |
Output is correct |
68 |
Correct |
13 ms |
248 KB |
Output is correct |
69 |
Correct |
9 ms |
312 KB |
Output is correct |
70 |
Correct |
7 ms |
308 KB |
Output is correct |
71 |
Partially correct |
80 ms |
248 KB |
Partially correct - number of queries: 9737 |
72 |
Correct |
14 ms |
392 KB |
Output is correct |
73 |
Partially correct |
81 ms |
376 KB |
Partially correct - number of queries: 9603 |
74 |
Partially correct |
97 ms |
248 KB |
Partially correct - number of queries: 9668 |
75 |
Correct |
9 ms |
380 KB |
Output is correct |
76 |
Partially correct |
43 ms |
396 KB |
Partially correct - number of queries: 8331 |
77 |
Partially correct |
102 ms |
376 KB |
Partially correct - number of queries: 9569 |
78 |
Correct |
14 ms |
248 KB |
Output is correct |
79 |
Correct |
25 ms |
376 KB |
Output is correct |
80 |
Partially correct |
90 ms |
376 KB |
Partially correct - number of queries: 9602 |
81 |
Partially correct |
96 ms |
248 KB |
Partially correct - number of queries: 9609 |
82 |
Partially correct |
73 ms |
248 KB |
Partially correct - number of queries: 9529 |
83 |
Correct |
8 ms |
248 KB |
Output is correct |
84 |
Partially correct |
52 ms |
248 KB |
Partially correct - number of queries: 7932 |
85 |
Partially correct |
55 ms |
376 KB |
Partially correct - number of queries: 9600 |
86 |
Correct |
13 ms |
376 KB |
Output is correct |
87 |
Correct |
5 ms |
312 KB |
Output is correct |
88 |
Correct |
10 ms |
248 KB |
Output is correct |
89 |
Correct |
10 ms |
332 KB |
Output is correct |
90 |
Correct |
7 ms |
248 KB |
Output is correct |
91 |
Correct |
10 ms |
248 KB |
Output is correct |
92 |
Correct |
7 ms |
424 KB |
Output is correct |
93 |
Correct |
18 ms |
376 KB |
Output is correct |
94 |
Correct |
21 ms |
248 KB |
Output is correct |
95 |
Correct |
16 ms |
376 KB |
Output is correct |
96 |
Correct |
14 ms |
380 KB |
Output is correct |
97 |
Correct |
11 ms |
248 KB |
Output is correct |