#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;
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];
break;
}
if(a[mid][0] != a[i][0] || a[mid][1] != a[i][1]) fim = mid - 1;
else ini = mid;
}
i = ini;
}
}
return n - 1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4936 KB |
Output is correct |
2 |
Correct |
4 ms |
4888 KB |
Output is correct |
3 |
Correct |
4 ms |
4936 KB |
Output is correct |
4 |
Correct |
4 ms |
4900 KB |
Output is correct |
5 |
Correct |
4 ms |
4896 KB |
Output is correct |
6 |
Correct |
4 ms |
4936 KB |
Output is correct |
7 |
Correct |
4 ms |
4884 KB |
Output is correct |
8 |
Correct |
4 ms |
4892 KB |
Output is correct |
9 |
Correct |
4 ms |
4936 KB |
Output is correct |
10 |
Correct |
4 ms |
4936 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4896 KB |
Output is correct |
2 |
Correct |
4 ms |
4892 KB |
Output is correct |
3 |
Correct |
4 ms |
4896 KB |
Output is correct |
4 |
Correct |
4 ms |
4936 KB |
Output is correct |
5 |
Correct |
4 ms |
4892 KB |
Output is correct |
6 |
Correct |
4 ms |
4892 KB |
Output is correct |
7 |
Correct |
4 ms |
4936 KB |
Output is correct |
8 |
Correct |
4 ms |
4868 KB |
Output is correct |
9 |
Correct |
4 ms |
4936 KB |
Output is correct |
10 |
Correct |
4 ms |
4936 KB |
Output is correct |
11 |
Correct |
6 ms |
4892 KB |
Output is correct |
12 |
Correct |
4 ms |
4936 KB |
Output is correct |
13 |
Correct |
6 ms |
5012 KB |
Output is correct |
14 |
Correct |
5 ms |
808 KB |
Output is correct |
15 |
Correct |
12 ms |
4928 KB |
Output is correct |
16 |
Partially correct |
79 ms |
5080 KB |
Partially correct - number of queries: 6834 |
17 |
Correct |
4 ms |
4892 KB |
Output is correct |
18 |
Partially correct |
69 ms |
5136 KB |
Partially correct - number of queries: 7981 |
19 |
Correct |
4 ms |
4884 KB |
Output is correct |
20 |
Correct |
11 ms |
2736 KB |
Output is correct |
21 |
Correct |
41 ms |
5012 KB |
Output is correct |
22 |
Correct |
11 ms |
4980 KB |
Output is correct |
23 |
Correct |
4 ms |
4936 KB |
Output is correct |
24 |
Correct |
4 ms |
4928 KB |
Output is correct |
25 |
Correct |
61 ms |
5056 KB |
Output is correct |
26 |
Correct |
54 ms |
5312 KB |
Output is correct |
27 |
Correct |
4 ms |
4936 KB |
Output is correct |
28 |
Partially correct |
38 ms |
5212 KB |
Partially correct - number of queries: 7497 |
29 |
Partially correct |
33 ms |
5144 KB |
Partially correct - number of queries: 5713 |
30 |
Partially correct |
100 ms |
5212 KB |
Partially correct - number of queries: 7931 |
31 |
Correct |
4 ms |
4928 KB |
Output is correct |
32 |
Correct |
9 ms |
4984 KB |
Output is correct |
33 |
Correct |
1 ms |
200 KB |
Output is correct |
34 |
Correct |
26 ms |
5056 KB |
Output is correct |
35 |
Correct |
4 ms |
5044 KB |
Output is correct |
36 |
Correct |
28 ms |
5012 KB |
Output is correct |
37 |
Correct |
6 ms |
4928 KB |
Output is correct |
38 |
Correct |
4 ms |
4896 KB |
Output is correct |
39 |
Correct |
54 ms |
5056 KB |
Output is correct |
40 |
Partially correct |
70 ms |
5108 KB |
Partially correct - number of queries: 6797 |
41 |
Correct |
64 ms |
5012 KB |
Output is correct |
42 |
Correct |
63 ms |
5056 KB |
Output is correct |
43 |
Correct |
45 ms |
4996 KB |
Output is correct |
44 |
Correct |
32 ms |
5056 KB |
Output is correct |
45 |
Correct |
34 ms |
5060 KB |
Output is correct |
46 |
Correct |
4 ms |
4888 KB |
Output is correct |
47 |
Correct |
24 ms |
5096 KB |
Output is correct |
48 |
Partially correct |
62 ms |
5148 KB |
Partially correct - number of queries: 5923 |
49 |
Correct |
7 ms |
5012 KB |
Output is correct |
50 |
Partially correct |
64 ms |
5148 KB |
Partially correct - number of queries: 7991 |
51 |
Correct |
44 ms |
5000 KB |
Output is correct |
52 |
Correct |
5 ms |
4936 KB |
Output is correct |
53 |
Correct |
4 ms |
5040 KB |
Output is correct |
54 |
Correct |
41 ms |
5056 KB |
Output is correct |
55 |
Correct |
4 ms |
4936 KB |
Output is correct |
56 |
Partially correct |
68 ms |
5144 KB |
Partially correct - number of queries: 7989 |
57 |
Partially correct |
72 ms |
5400 KB |
Partially correct - number of queries: 5823 |
58 |
Partially correct |
73 ms |
5184 KB |
Partially correct - number of queries: 5920 |
59 |
Correct |
66 ms |
5008 KB |
Output is correct |
60 |
Correct |
60 ms |
5108 KB |
Output is correct |
61 |
Correct |
4 ms |
4992 KB |
Output is correct |
62 |
Correct |
3 ms |
4884 KB |
Output is correct |
63 |
Correct |
4 ms |
4936 KB |
Output is correct |
64 |
Correct |
4 ms |
5044 KB |
Output is correct |
65 |
Correct |
4 ms |
4892 KB |
Output is correct |
66 |
Correct |
6 ms |
5052 KB |
Output is correct |
67 |
Correct |
4 ms |
4896 KB |
Output is correct |
68 |
Correct |
5 ms |
5004 KB |
Output is correct |
69 |
Correct |
10 ms |
5000 KB |
Output is correct |
70 |
Correct |
4 ms |
4948 KB |
Output is correct |
71 |
Partially correct |
99 ms |
5184 KB |
Partially correct - number of queries: 8227 |
72 |
Correct |
11 ms |
4936 KB |
Output is correct |
73 |
Partially correct |
41 ms |
5236 KB |
Partially correct - number of queries: 8131 |
74 |
Partially correct |
108 ms |
5184 KB |
Partially correct - number of queries: 8184 |
75 |
Correct |
5 ms |
4936 KB |
Output is correct |
76 |
Partially correct |
91 ms |
5188 KB |
Partially correct - number of queries: 7011 |
77 |
Partially correct |
77 ms |
5312 KB |
Partially correct - number of queries: 8196 |
78 |
Correct |
11 ms |
4936 KB |
Output is correct |
79 |
Correct |
47 ms |
5000 KB |
Output is correct |
80 |
Partially correct |
75 ms |
5184 KB |
Partially correct - number of queries: 8176 |
81 |
Partially correct |
108 ms |
5280 KB |
Partially correct - number of queries: 8235 |
82 |
Partially correct |
90 ms |
5148 KB |
Partially correct - number of queries: 8104 |
83 |
Correct |
5 ms |
4936 KB |
Output is correct |
84 |
Partially correct |
86 ms |
5184 KB |
Partially correct - number of queries: 6701 |
85 |
Partially correct |
80 ms |
5184 KB |
Partially correct - number of queries: 8180 |
86 |
Partially correct |
72 ms |
5056 KB |
Partially correct - number of queries: 6083 |
87 |
Correct |
8 ms |
4936 KB |
Output is correct |
88 |
Partially correct |
53 ms |
5192 KB |
Partially correct - number of queries: 5742 |
89 |
Partially correct |
49 ms |
5168 KB |
Partially correct - number of queries: 6030 |
90 |
Correct |
5 ms |
4888 KB |
Output is correct |
91 |
Correct |
21 ms |
5048 KB |
Output is correct |
92 |
Correct |
4 ms |
4936 KB |
Output is correct |
93 |
Correct |
7 ms |
5004 KB |
Output is correct |
94 |
Correct |
8 ms |
4936 KB |
Output is correct |
95 |
Correct |
9 ms |
4936 KB |
Output is correct |
96 |
Correct |
9 ms |
4936 KB |
Output is correct |
97 |
Correct |
4 ms |
4936 KB |
Output is correct |