#include "prize.h"
#include<bits/stdc++.h>
using namespace std;
int find_best(int n) {
vector<vector<int> > a(n);
int maxi = 0;
for(int i = 0; i < n; i++){
if(a[i].empty()) a[i] = ask(i);
if(a[i][0] == 0 && a[i][1] == 0) return i;
if(a[i][0] + a[i][1] > maxi) maxi = a[i][0] + a[i][1];
if(a[i][0] + a[i][1] == maxi){
int ini = i, fim = n - 1;
bool flag = false;
while(ini != fim){
int mid = (ini + fim) >> 1;
if(ini == fim - 1) mid = fim;
if(a[mid].empty()) a[mid] = ask(mid);
if(a[mid][0] == 0 && a[mid][1] == 0) return mid;
if(a[mid][0] + a[mid][1] > maxi){
maxi = a[mid][0] + a[mid][1];
flag = true;
break;
}
if(a[mid][0] != a[i][0] || a[mid][1] != a[i][1]) fim = mid - 1;
else ini = mid;
}
if(!flag) i = ini;
}
}
return n - 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4936 KB |
Output is correct |
2 |
Correct |
3 ms |
4936 KB |
Output is correct |
3 |
Correct |
3 ms |
4888 KB |
Output is correct |
4 |
Correct |
4 ms |
4892 KB |
Output is correct |
5 |
Correct |
4 ms |
4936 KB |
Output is correct |
6 |
Correct |
4 ms |
4892 KB |
Output is correct |
7 |
Correct |
4 ms |
4936 KB |
Output is correct |
8 |
Correct |
3 ms |
4888 KB |
Output is correct |
9 |
Correct |
4 ms |
4884 KB |
Output is correct |
10 |
Correct |
4 ms |
4936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4936 KB |
Output is correct |
2 |
Correct |
4 ms |
4936 KB |
Output is correct |
3 |
Correct |
3 ms |
4888 KB |
Output is correct |
4 |
Correct |
4 ms |
4936 KB |
Output is correct |
5 |
Correct |
4 ms |
4936 KB |
Output is correct |
6 |
Correct |
4 ms |
4936 KB |
Output is correct |
7 |
Correct |
4 ms |
4928 KB |
Output is correct |
8 |
Correct |
4 ms |
4888 KB |
Output is correct |
9 |
Correct |
3 ms |
4932 KB |
Output is correct |
10 |
Correct |
3 ms |
4936 KB |
Output is correct |
11 |
Correct |
6 ms |
4936 KB |
Output is correct |
12 |
Correct |
4 ms |
4936 KB |
Output is correct |
13 |
Correct |
9 ms |
4936 KB |
Output is correct |
14 |
Correct |
4 ms |
712 KB |
Output is correct |
15 |
Correct |
17 ms |
4936 KB |
Output is correct |
16 |
Partially correct |
60 ms |
5068 KB |
Partially correct - number of queries: 6834 |
17 |
Correct |
3 ms |
4924 KB |
Output is correct |
18 |
Partially correct |
39 ms |
5224 KB |
Partially correct - number of queries: 7981 |
19 |
Correct |
4 ms |
4936 KB |
Output is correct |
20 |
Correct |
21 ms |
2672 KB |
Output is correct |
21 |
Correct |
42 ms |
5000 KB |
Output is correct |
22 |
Correct |
11 ms |
4980 KB |
Output is correct |
23 |
Correct |
4 ms |
4936 KB |
Output is correct |
24 |
Correct |
3 ms |
4880 KB |
Output is correct |
25 |
Correct |
58 ms |
5056 KB |
Output is correct |
26 |
Correct |
24 ms |
5120 KB |
Output is correct |
27 |
Correct |
5 ms |
4892 KB |
Output is correct |
28 |
Partially correct |
69 ms |
5184 KB |
Partially correct - number of queries: 7497 |
29 |
Partially correct |
37 ms |
5120 KB |
Partially correct - number of queries: 5713 |
30 |
Partially correct |
39 ms |
5228 KB |
Partially correct - number of queries: 7931 |
31 |
Correct |
4 ms |
4888 KB |
Output is correct |
32 |
Correct |
9 ms |
4888 KB |
Output is correct |
33 |
Correct |
1 ms |
200 KB |
Output is correct |
34 |
Correct |
15 ms |
5116 KB |
Output is correct |
35 |
Correct |
6 ms |
4928 KB |
Output is correct |
36 |
Correct |
20 ms |
5012 KB |
Output is correct |
37 |
Correct |
5 ms |
4884 KB |
Output is correct |
38 |
Correct |
4 ms |
4928 KB |
Output is correct |
39 |
Correct |
22 ms |
5204 KB |
Output is correct |
40 |
Partially correct |
86 ms |
5180 KB |
Partially correct - number of queries: 6797 |
41 |
Correct |
45 ms |
5296 KB |
Output is correct |
42 |
Correct |
43 ms |
5020 KB |
Output is correct |
43 |
Correct |
45 ms |
5056 KB |
Output is correct |
44 |
Correct |
32 ms |
5012 KB |
Output is correct |
45 |
Correct |
29 ms |
5140 KB |
Output is correct |
46 |
Correct |
4 ms |
4928 KB |
Output is correct |
47 |
Correct |
47 ms |
5056 KB |
Output is correct |
48 |
Partially correct |
30 ms |
5168 KB |
Partially correct - number of queries: 5923 |
49 |
Correct |
11 ms |
4936 KB |
Output is correct |
50 |
Partially correct |
39 ms |
5240 KB |
Partially correct - number of queries: 7991 |
51 |
Correct |
18 ms |
5096 KB |
Output is correct |
52 |
Correct |
4 ms |
4928 KB |
Output is correct |
53 |
Correct |
5 ms |
4928 KB |
Output is correct |
54 |
Correct |
40 ms |
5024 KB |
Output is correct |
55 |
Correct |
4 ms |
4936 KB |
Output is correct |
56 |
Partially correct |
104 ms |
5184 KB |
Partially correct - number of queries: 7989 |
57 |
Partially correct |
64 ms |
5056 KB |
Partially correct - number of queries: 5823 |
58 |
Partially correct |
75 ms |
5060 KB |
Partially correct - number of queries: 5920 |
59 |
Correct |
58 ms |
5056 KB |
Output is correct |
60 |
Correct |
24 ms |
5196 KB |
Output is correct |
61 |
Correct |
5 ms |
4888 KB |
Output is correct |
62 |
Correct |
4 ms |
4936 KB |
Output is correct |
63 |
Correct |
5 ms |
4888 KB |
Output is correct |
64 |
Correct |
4 ms |
4896 KB |
Output is correct |
65 |
Correct |
4 ms |
4936 KB |
Output is correct |
66 |
Correct |
8 ms |
4888 KB |
Output is correct |
67 |
Correct |
4 ms |
4936 KB |
Output is correct |
68 |
Correct |
6 ms |
5044 KB |
Output is correct |
69 |
Correct |
9 ms |
4892 KB |
Output is correct |
70 |
Correct |
4 ms |
4936 KB |
Output is correct |
71 |
Partially correct |
108 ms |
5184 KB |
Partially correct - number of queries: 8227 |
72 |
Correct |
8 ms |
5016 KB |
Output is correct |
73 |
Partially correct |
69 ms |
5184 KB |
Partially correct - number of queries: 8131 |
74 |
Partially correct |
96 ms |
5184 KB |
Partially correct - number of queries: 8184 |
75 |
Correct |
4 ms |
4936 KB |
Output is correct |
76 |
Partially correct |
90 ms |
5128 KB |
Partially correct - number of queries: 7011 |
77 |
Partially correct |
94 ms |
5184 KB |
Partially correct - number of queries: 8196 |
78 |
Correct |
9 ms |
4936 KB |
Output is correct |
79 |
Correct |
48 ms |
5008 KB |
Output is correct |
80 |
Partially correct |
101 ms |
5184 KB |
Partially correct - number of queries: 8176 |
81 |
Partially correct |
43 ms |
5264 KB |
Partially correct - number of queries: 8235 |
82 |
Partially correct |
87 ms |
5124 KB |
Partially correct - number of queries: 8104 |
83 |
Correct |
6 ms |
4936 KB |
Output is correct |
84 |
Partially correct |
70 ms |
5400 KB |
Partially correct - number of queries: 6701 |
85 |
Partially correct |
107 ms |
5184 KB |
Partially correct - number of queries: 8180 |
86 |
Partially correct |
68 ms |
5056 KB |
Partially correct - number of queries: 6428 |
87 |
Correct |
9 ms |
4936 KB |
Output is correct |
88 |
Partially correct |
79 ms |
5108 KB |
Partially correct - number of queries: 6020 |
89 |
Partially correct |
72 ms |
5124 KB |
Partially correct - number of queries: 6386 |
90 |
Correct |
4 ms |
4936 KB |
Output is correct |
91 |
Correct |
46 ms |
5056 KB |
Output is correct |
92 |
Correct |
33 ms |
5004 KB |
Output is correct |
93 |
Correct |
9 ms |
4936 KB |
Output is correct |
94 |
Correct |
9 ms |
4936 KB |
Output is correct |
95 |
Correct |
9 ms |
5012 KB |
Output is correct |
96 |
Correct |
7 ms |
4936 KB |
Output is correct |
97 |
Correct |
3 ms |
4936 KB |
Output is correct |