#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
using P=pair<int,int>;
/*vector<int> s;
vector<int> ask(int id){
cout<<id<<endl;
int a,b;cin>>a>>b;
vector<int> res{a,b};
return res;
}*/
int find_best(int n) {
vector<int> a;
vector<P> v(n,P(-1,-1));
int en=n;
int cnt=0;
int ma=0;
for(int i=0;i<min(n,500);i++){
a=ask(i);
ma=max(ma,a[0]+a[1]);
v[i]=P(a[0],a[1]);
}
while(1){
int ok=0,ng=en;
while(ng-ok>1){
int mid=(ok+ng)/2;
if(v[mid].first==-1){
a=ask(mid);
v[mid]=P(a[0],a[1]);
}
if(v[mid].second==cnt){
if(v[mid].second+v[mid].first==ma){
ng=mid;
}else{
ok=mid;
}
}else{
ok=mid;
}
}
// cout<<ok<<endl;
if(v[ok].first+v[ok].second==0){
return ok;
}
en=ok;
cnt++;
}
return 0;
}
/*int main(){
int n;cin>>n;
s.resize(n);
for(int i=0;i<n;i++){
cin>>s[i];
}
cout<<find_best(n)<<endl;
}*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
1912 KB |
Output is correct |
2 |
Correct |
10 ms |
1912 KB |
Output is correct |
3 |
Correct |
10 ms |
1784 KB |
Output is correct |
4 |
Correct |
10 ms |
1912 KB |
Output is correct |
5 |
Correct |
9 ms |
1784 KB |
Output is correct |
6 |
Correct |
10 ms |
1912 KB |
Output is correct |
7 |
Correct |
8 ms |
2040 KB |
Output is correct |
8 |
Correct |
9 ms |
1912 KB |
Output is correct |
9 |
Correct |
10 ms |
1784 KB |
Output is correct |
10 |
Correct |
10 ms |
1784 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
1912 KB |
Output is correct |
2 |
Correct |
12 ms |
1784 KB |
Output is correct |
3 |
Correct |
10 ms |
1912 KB |
Output is correct |
4 |
Correct |
9 ms |
1784 KB |
Output is correct |
5 |
Correct |
12 ms |
1912 KB |
Output is correct |
6 |
Correct |
9 ms |
1912 KB |
Output is correct |
7 |
Correct |
9 ms |
1784 KB |
Output is correct |
8 |
Correct |
11 ms |
1912 KB |
Output is correct |
9 |
Correct |
11 ms |
1784 KB |
Output is correct |
10 |
Correct |
10 ms |
1784 KB |
Output is correct |
11 |
Correct |
12 ms |
2040 KB |
Output is correct |
12 |
Correct |
14 ms |
1784 KB |
Output is correct |
13 |
Correct |
11 ms |
1784 KB |
Output is correct |
14 |
Correct |
23 ms |
376 KB |
Output is correct |
15 |
Partially correct |
36 ms |
2040 KB |
Partially correct - number of queries: 6539 |
16 |
Correct |
20 ms |
1784 KB |
Output is correct |
17 |
Partially correct |
72 ms |
1784 KB |
Partially correct - number of queries: 7945 |
18 |
Correct |
10 ms |
1784 KB |
Output is correct |
19 |
Partially correct |
67 ms |
1912 KB |
Partially correct - number of queries: 7304 |
20 |
Correct |
36 ms |
1016 KB |
Output is correct |
21 |
Partially correct |
44 ms |
1912 KB |
Partially correct - number of queries: 5504 |
22 |
Partially correct |
49 ms |
1784 KB |
Partially correct - number of queries: 5679 |
23 |
Correct |
10 ms |
1844 KB |
Output is correct |
24 |
Correct |
13 ms |
1912 KB |
Output is correct |
25 |
Correct |
44 ms |
1912 KB |
Output is correct |
26 |
Correct |
37 ms |
1788 KB |
Output is correct |
27 |
Correct |
8 ms |
1844 KB |
Output is correct |
28 |
Correct |
13 ms |
1912 KB |
Output is correct |
29 |
Correct |
12 ms |
1912 KB |
Output is correct |
30 |
Correct |
10 ms |
1912 KB |
Output is correct |
31 |
Partially correct |
65 ms |
1912 KB |
Partially correct - number of queries: 7604 |
32 |
Correct |
11 ms |
1784 KB |
Output is correct |
33 |
Correct |
6 ms |
300 KB |
Output is correct |
34 |
Partially correct |
62 ms |
1912 KB |
Partially correct - number of queries: 6028 |
35 |
Correct |
11 ms |
1912 KB |
Output is correct |
36 |
Partially correct |
66 ms |
1784 KB |
Partially correct - number of queries: 6582 |
37 |
Correct |
12 ms |
1912 KB |
Output is correct |
38 |
Correct |
10 ms |
1784 KB |
Output is correct |
39 |
Correct |
46 ms |
1784 KB |
Output is correct |
40 |
Correct |
10 ms |
1784 KB |
Output is correct |
41 |
Correct |
38 ms |
1784 KB |
Output is correct |
42 |
Correct |
39 ms |
1912 KB |
Output is correct |
43 |
Correct |
37 ms |
1784 KB |
Output is correct |
44 |
Partially correct |
33 ms |
1848 KB |
Partially correct - number of queries: 5420 |
45 |
Partially correct |
49 ms |
1944 KB |
Partially correct - number of queries: 5920 |
46 |
Partially correct |
71 ms |
1912 KB |
Partially correct - number of queries: 7943 |
47 |
Correct |
48 ms |
1912 KB |
Output is correct |
48 |
Correct |
19 ms |
1964 KB |
Output is correct |
49 |
Partially correct |
41 ms |
1912 KB |
Partially correct - number of queries: 7627 |
50 |
Correct |
11 ms |
1788 KB |
Output is correct |
51 |
Partially correct |
47 ms |
1784 KB |
Partially correct - number of queries: 5379 |
52 |
Partially correct |
63 ms |
1784 KB |
Partially correct - number of queries: 7914 |
53 |
Correct |
10 ms |
1912 KB |
Output is correct |
54 |
Partially correct |
46 ms |
1784 KB |
Partially correct - number of queries: 5168 |
55 |
Partially correct |
70 ms |
1784 KB |
Partially correct - number of queries: 7944 |
56 |
Correct |
10 ms |
1784 KB |
Output is correct |
57 |
Correct |
33 ms |
1912 KB |
Output is correct |
58 |
Correct |
32 ms |
1784 KB |
Output is correct |
59 |
Correct |
36 ms |
1784 KB |
Output is correct |
60 |
Correct |
41 ms |
1784 KB |
Output is correct |
61 |
Correct |
8 ms |
1912 KB |
Output is correct |
62 |
Correct |
9 ms |
2040 KB |
Output is correct |
63 |
Correct |
10 ms |
1784 KB |
Output is correct |
64 |
Correct |
9 ms |
1844 KB |
Output is correct |
65 |
Correct |
12 ms |
1784 KB |
Output is correct |
66 |
Correct |
12 ms |
1912 KB |
Output is correct |
67 |
Correct |
43 ms |
1788 KB |
Output is correct |
68 |
Correct |
13 ms |
1784 KB |
Output is correct |
69 |
Correct |
12 ms |
1784 KB |
Output is correct |
70 |
Correct |
30 ms |
1784 KB |
Output is correct |
71 |
Partially correct |
81 ms |
1912 KB |
Partially correct - number of queries: 8128 |
72 |
Correct |
15 ms |
1784 KB |
Output is correct |
73 |
Partially correct |
75 ms |
1784 KB |
Partially correct - number of queries: 7989 |
74 |
Partially correct |
80 ms |
1784 KB |
Partially correct - number of queries: 8074 |
75 |
Correct |
14 ms |
1912 KB |
Output is correct |
76 |
Partially correct |
63 ms |
1784 KB |
Partially correct - number of queries: 7034 |
77 |
Partially correct |
78 ms |
1784 KB |
Partially correct - number of queries: 8078 |
78 |
Correct |
14 ms |
1784 KB |
Output is correct |
79 |
Correct |
35 ms |
1784 KB |
Output is correct |
80 |
Partially correct |
63 ms |
1912 KB |
Partially correct - number of queries: 8070 |
81 |
Partially correct |
76 ms |
1784 KB |
Partially correct - number of queries: 8067 |
82 |
Partially correct |
67 ms |
1784 KB |
Partially correct - number of queries: 8000 |
83 |
Correct |
10 ms |
1784 KB |
Output is correct |
84 |
Partially correct |
54 ms |
1784 KB |
Partially correct - number of queries: 6646 |
85 |
Partially correct |
74 ms |
1912 KB |
Partially correct - number of queries: 8008 |
86 |
Correct |
10 ms |
1784 KB |
Output is correct |
87 |
Correct |
10 ms |
1916 KB |
Output is correct |
88 |
Correct |
12 ms |
1912 KB |
Output is correct |
89 |
Correct |
10 ms |
1912 KB |
Output is correct |
90 |
Correct |
11 ms |
1912 KB |
Output is correct |
91 |
Correct |
9 ms |
1784 KB |
Output is correct |
92 |
Correct |
13 ms |
1784 KB |
Output is correct |
93 |
Correct |
13 ms |
1784 KB |
Output is correct |
94 |
Correct |
13 ms |
1912 KB |
Output is correct |
95 |
Correct |
13 ms |
1784 KB |
Output is correct |
96 |
Correct |
13 ms |
1788 KB |
Output is correct |
97 |
Correct |
10 ms |
1784 KB |
Output is correct |