#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include "prize.h"
using namespace std;
const int MAX_N=2e5+4;
int asked[MAX_N][2];
bool used[MAX_N];
pair<int,int>query(int pos)
{
if(used[pos])return {asked[pos][0],asked[pos][1]};
used[pos]=1;
auto ve=ask(pos);
asked[pos][0]=ve[0];
asked[pos][1]=ve[1];
return {ve[0],ve[1]};
}
int find_best(int n)
{
int prevpos=-1;
int qq=480;
int big=-1e9;
while(qq--)
{
prevpos++;
auto cur=query(prevpos);
int all=cur.first+cur.second;
if(all==0)return prevpos;
big=max(big,all);
}
while(1)
{
prevpos++;
auto cur=query(prevpos);
int all=cur.first+cur.second;
if(all==big)
{
int l=prevpos,r=n-1;
while(l<=r)
{
int mid=(l+r)/2;
auto cur2=query(mid);
if(cur2==cur)
{
prevpos=mid;
l=mid+1;
}
else r=mid-1;
}
}
else
{
if(all==0)return prevpos;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
600 KB |
Output is correct |
2 |
Correct |
3 ms |
344 KB |
Output is correct |
3 |
Correct |
2 ms |
344 KB |
Output is correct |
4 |
Correct |
4 ms |
344 KB |
Output is correct |
5 |
Correct |
3 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
3 ms |
340 KB |
Output is correct |
8 |
Correct |
4 ms |
344 KB |
Output is correct |
9 |
Correct |
3 ms |
344 KB |
Output is correct |
10 |
Correct |
3 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
340 KB |
Output is correct |
2 |
Correct |
4 ms |
600 KB |
Output is correct |
3 |
Correct |
3 ms |
344 KB |
Output is correct |
4 |
Correct |
2 ms |
448 KB |
Output is correct |
5 |
Correct |
3 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
4 ms |
456 KB |
Output is correct |
8 |
Correct |
3 ms |
344 KB |
Output is correct |
9 |
Correct |
3 ms |
448 KB |
Output is correct |
10 |
Correct |
2 ms |
344 KB |
Output is correct |
11 |
Correct |
5 ms |
856 KB |
Output is correct |
12 |
Correct |
2 ms |
344 KB |
Output is correct |
13 |
Correct |
7 ms |
1212 KB |
Output is correct |
14 |
Correct |
4 ms |
344 KB |
Output is correct |
15 |
Correct |
10 ms |
1172 KB |
Output is correct |
16 |
Partially correct |
47 ms |
1868 KB |
Partially correct - number of queries: 7190 |
17 |
Correct |
4 ms |
344 KB |
Output is correct |
18 |
Partially correct |
36 ms |
2084 KB |
Partially correct - number of queries: 8351 |
19 |
Correct |
3 ms |
344 KB |
Output is correct |
20 |
Correct |
11 ms |
964 KB |
Output is correct |
21 |
Correct |
14 ms |
1612 KB |
Output is correct |
22 |
Correct |
7 ms |
856 KB |
Output is correct |
23 |
Correct |
2 ms |
344 KB |
Output is correct |
24 |
Correct |
4 ms |
344 KB |
Output is correct |
25 |
Correct |
29 ms |
1616 KB |
Output is correct |
26 |
Correct |
30 ms |
1868 KB |
Output is correct |
27 |
Correct |
3 ms |
600 KB |
Output is correct |
28 |
Partially correct |
37 ms |
2284 KB |
Partially correct - number of queries: 7878 |
29 |
Partially correct |
28 ms |
2036 KB |
Partially correct - number of queries: 6114 |
30 |
Partially correct |
54 ms |
2020 KB |
Partially correct - number of queries: 8279 |
31 |
Correct |
2 ms |
344 KB |
Output is correct |
32 |
Correct |
5 ms |
1112 KB |
Output is correct |
33 |
Correct |
0 ms |
344 KB |
Output is correct |
34 |
Correct |
15 ms |
1452 KB |
Output is correct |
35 |
Correct |
5 ms |
600 KB |
Output is correct |
36 |
Correct |
8 ms |
1160 KB |
Output is correct |
37 |
Correct |
3 ms |
600 KB |
Output is correct |
38 |
Correct |
2 ms |
344 KB |
Output is correct |
39 |
Correct |
19 ms |
1692 KB |
Output is correct |
40 |
Partially correct |
34 ms |
2132 KB |
Partially correct - number of queries: 7166 |
41 |
Partially correct |
29 ms |
2096 KB |
Partially correct - number of queries: 5210 |
42 |
Partially correct |
22 ms |
2228 KB |
Partially correct - number of queries: 5210 |
43 |
Correct |
21 ms |
1700 KB |
Output is correct |
44 |
Correct |
15 ms |
1616 KB |
Output is correct |
45 |
Correct |
10 ms |
1360 KB |
Output is correct |
46 |
Correct |
2 ms |
344 KB |
Output is correct |
47 |
Correct |
25 ms |
1472 KB |
Output is correct |
48 |
Partially correct |
36 ms |
1872 KB |
Partially correct - number of queries: 6307 |
49 |
Correct |
5 ms |
856 KB |
Output is correct |
50 |
Partially correct |
44 ms |
2144 KB |
Partially correct - number of queries: 8351 |
51 |
Correct |
21 ms |
1616 KB |
Output is correct |
52 |
Correct |
4 ms |
344 KB |
Output is correct |
53 |
Correct |
5 ms |
856 KB |
Output is correct |
54 |
Correct |
18 ms |
1616 KB |
Output is correct |
55 |
Correct |
2 ms |
344 KB |
Output is correct |
56 |
Partially correct |
45 ms |
2168 KB |
Partially correct - number of queries: 8346 |
57 |
Partially correct |
42 ms |
1900 KB |
Partially correct - number of queries: 6210 |
58 |
Partially correct |
33 ms |
2064 KB |
Partially correct - number of queries: 6291 |
59 |
Partially correct |
30 ms |
1700 KB |
Partially correct - number of queries: 5207 |
60 |
Correct |
23 ms |
1612 KB |
Output is correct |
61 |
Correct |
3 ms |
600 KB |
Output is correct |
62 |
Correct |
4 ms |
344 KB |
Output is correct |
63 |
Correct |
3 ms |
756 KB |
Output is correct |
64 |
Correct |
3 ms |
600 KB |
Output is correct |
65 |
Correct |
2 ms |
344 KB |
Output is correct |
66 |
Correct |
5 ms |
344 KB |
Output is correct |
67 |
Correct |
3 ms |
344 KB |
Output is correct |
68 |
Correct |
2 ms |
344 KB |
Output is correct |
69 |
Correct |
3 ms |
344 KB |
Output is correct |
70 |
Correct |
2 ms |
340 KB |
Output is correct |
71 |
Partially correct |
50 ms |
2400 KB |
Partially correct - number of queries: 8258 |
72 |
Correct |
5 ms |
1476 KB |
Output is correct |
73 |
Partially correct |
56 ms |
2324 KB |
Partially correct - number of queries: 8144 |
74 |
Partially correct |
52 ms |
2340 KB |
Partially correct - number of queries: 8190 |
75 |
Correct |
3 ms |
708 KB |
Output is correct |
76 |
Partially correct |
31 ms |
2264 KB |
Partially correct - number of queries: 7101 |
77 |
Partially correct |
44 ms |
2128 KB |
Partially correct - number of queries: 8387 |
78 |
Correct |
6 ms |
1368 KB |
Output is correct |
79 |
Correct |
19 ms |
2416 KB |
Output is correct |
80 |
Partially correct |
58 ms |
1952 KB |
Partially correct - number of queries: 8441 |
81 |
Partially correct |
50 ms |
2044 KB |
Partially correct - number of queries: 8388 |
82 |
Partially correct |
41 ms |
2148 KB |
Partially correct - number of queries: 8319 |
83 |
Correct |
3 ms |
600 KB |
Output is correct |
84 |
Partially correct |
29 ms |
2040 KB |
Partially correct - number of queries: 6939 |
85 |
Partially correct |
56 ms |
2124 KB |
Partially correct - number of queries: 8345 |
86 |
Correct |
3 ms |
600 KB |
Output is correct |
87 |
Correct |
2 ms |
344 KB |
Output is correct |
88 |
Correct |
4 ms |
344 KB |
Output is correct |
89 |
Correct |
3 ms |
344 KB |
Output is correct |
90 |
Correct |
2 ms |
448 KB |
Output is correct |
91 |
Correct |
3 ms |
340 KB |
Output is correct |
92 |
Correct |
5 ms |
704 KB |
Output is correct |
93 |
Correct |
5 ms |
1112 KB |
Output is correct |
94 |
Correct |
4 ms |
1112 KB |
Output is correct |
95 |
Correct |
3 ms |
1112 KB |
Output is correct |
96 |
Correct |
3 ms |
1112 KB |
Output is correct |
97 |
Correct |
5 ms |
344 KB |
Output is correct |