/*input
8
3 2 3 1 3 3 2 3
*/
#include "prize.h"
#include<bits/stdc++.h>
using namespace std;
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=2e3+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
return (a*b)%MOD;
}
ll mypow(ll a,ll b){
if(b<=0) return 1;
a%=MOD;
ll res=1LL;
while(b){
if(b&1) res=mult(res,a);
a=mult(a,a);
b>>=1;
}
return res;
}
int find_best(int n) {
int x=0,p=-1;
REP(i,min(n,500)){
vector<int> v=ask(i);
if(v[0]==0 and v[1]==0){
return i;
}
if(x<v[0]+v[1]){
x=v[0]+v[1];
p=i;
}
}
while(p<n){
int l=p,r=n-1;
vector<int> z=ask(p);
while(l<r){
int mid=(l+r+1)/2;
vector<int> v=ask(mid);
if(v[1]<z[1]){
r=mid-1;
}
else{
l=mid;
}
}
p=l+1;
while(p<n){
vector<int> v=ask(p);
if(v[0]+v[1]==x) break;
if(v[0]+v[1]==0){
return p;
}
++p;
}
}
return -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
364 KB |
Output is correct |
2 |
Correct |
7 ms |
364 KB |
Output is correct |
3 |
Correct |
3 ms |
492 KB |
Output is correct |
4 |
Correct |
7 ms |
364 KB |
Output is correct |
5 |
Correct |
7 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
3 ms |
492 KB |
Output is correct |
8 |
Correct |
7 ms |
364 KB |
Output is correct |
9 |
Correct |
5 ms |
364 KB |
Output is correct |
10 |
Correct |
7 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
364 KB |
Output is correct |
2 |
Correct |
5 ms |
364 KB |
Output is correct |
3 |
Correct |
4 ms |
364 KB |
Output is correct |
4 |
Correct |
4 ms |
364 KB |
Output is correct |
5 |
Correct |
5 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
4 ms |
364 KB |
Output is correct |
8 |
Correct |
7 ms |
364 KB |
Output is correct |
9 |
Correct |
7 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
364 KB |
Output is correct |
11 |
Correct |
8 ms |
364 KB |
Output is correct |
12 |
Correct |
6 ms |
364 KB |
Output is correct |
13 |
Correct |
10 ms |
364 KB |
Output is correct |
14 |
Correct |
9 ms |
364 KB |
Output is correct |
15 |
Correct |
24 ms |
364 KB |
Output is correct |
16 |
Partially correct |
54 ms |
492 KB |
Partially correct - number of queries: 8223 |
17 |
Correct |
5 ms |
364 KB |
Output is correct |
18 |
Partially correct |
83 ms |
384 KB |
Partially correct - number of queries: 9580 |
19 |
Correct |
6 ms |
364 KB |
Output is correct |
20 |
Correct |
23 ms |
364 KB |
Output is correct |
21 |
Correct |
31 ms |
364 KB |
Output is correct |
22 |
Correct |
10 ms |
364 KB |
Output is correct |
23 |
Correct |
7 ms |
364 KB |
Output is correct |
24 |
Correct |
7 ms |
364 KB |
Output is correct |
25 |
Partially correct |
67 ms |
364 KB |
Partially correct - number of queries: 5625 |
26 |
Partially correct |
54 ms |
364 KB |
Partially correct - number of queries: 5539 |
27 |
Correct |
8 ms |
364 KB |
Output is correct |
28 |
Partially correct |
88 ms |
368 KB |
Partially correct - number of queries: 9110 |
29 |
Partially correct |
54 ms |
364 KB |
Partially correct - number of queries: 7038 |
30 |
Partially correct |
81 ms |
364 KB |
Partially correct - number of queries: 9519 |
31 |
Correct |
5 ms |
364 KB |
Output is correct |
32 |
Correct |
13 ms |
364 KB |
Output is correct |
33 |
Correct |
1 ms |
364 KB |
Output is correct |
34 |
Correct |
31 ms |
364 KB |
Output is correct |
35 |
Correct |
7 ms |
364 KB |
Output is correct |
36 |
Correct |
14 ms |
492 KB |
Output is correct |
37 |
Correct |
4 ms |
492 KB |
Output is correct |
38 |
Correct |
5 ms |
364 KB |
Output is correct |
39 |
Correct |
35 ms |
364 KB |
Output is correct |
40 |
Partially correct |
44 ms |
364 KB |
Partially correct - number of queries: 8205 |
41 |
Partially correct |
45 ms |
364 KB |
Partially correct - number of queries: 5917 |
42 |
Partially correct |
52 ms |
364 KB |
Partially correct - number of queries: 5917 |
43 |
Partially correct |
50 ms |
364 KB |
Partially correct - number of queries: 5389 |
44 |
Correct |
32 ms |
364 KB |
Output is correct |
45 |
Correct |
45 ms |
364 KB |
Output is correct |
46 |
Correct |
6 ms |
364 KB |
Output is correct |
47 |
Correct |
36 ms |
364 KB |
Output is correct |
48 |
Partially correct |
89 ms |
368 KB |
Partially correct - number of queries: 7200 |
49 |
Correct |
12 ms |
364 KB |
Output is correct |
50 |
Partially correct |
76 ms |
364 KB |
Partially correct - number of queries: 9577 |
51 |
Correct |
37 ms |
492 KB |
Output is correct |
52 |
Correct |
8 ms |
364 KB |
Output is correct |
53 |
Correct |
6 ms |
364 KB |
Output is correct |
54 |
Correct |
53 ms |
364 KB |
Output is correct |
55 |
Correct |
4 ms |
364 KB |
Output is correct |
56 |
Partially correct |
73 ms |
364 KB |
Partially correct - number of queries: 9579 |
57 |
Partially correct |
57 ms |
364 KB |
Partially correct - number of queries: 7118 |
58 |
Partially correct |
74 ms |
364 KB |
Partially correct - number of queries: 7231 |
59 |
Partially correct |
57 ms |
364 KB |
Partially correct - number of queries: 5917 |
60 |
Partially correct |
69 ms |
364 KB |
Partially correct - number of queries: 5528 |
61 |
Correct |
9 ms |
364 KB |
Output is correct |
62 |
Correct |
7 ms |
364 KB |
Output is correct |
63 |
Correct |
7 ms |
364 KB |
Output is correct |
64 |
Correct |
8 ms |
364 KB |
Output is correct |
65 |
Correct |
6 ms |
364 KB |
Output is correct |
66 |
Correct |
11 ms |
628 KB |
Output is correct |
67 |
Correct |
5 ms |
364 KB |
Output is correct |
68 |
Correct |
5 ms |
364 KB |
Output is correct |
69 |
Correct |
12 ms |
364 KB |
Output is correct |
70 |
Correct |
4 ms |
492 KB |
Output is correct |
71 |
Partially correct |
80 ms |
364 KB |
Partially correct - number of queries: 9700 |
72 |
Correct |
15 ms |
364 KB |
Output is correct |
73 |
Partially correct |
86 ms |
364 KB |
Partially correct - number of queries: 9587 |
74 |
Partially correct |
77 ms |
364 KB |
Partially correct - number of queries: 9632 |
75 |
Correct |
6 ms |
364 KB |
Output is correct |
76 |
Partially correct |
63 ms |
364 KB |
Partially correct - number of queries: 8347 |
77 |
Partially correct |
73 ms |
364 KB |
Partially correct - number of queries: 9587 |
78 |
Correct |
12 ms |
384 KB |
Output is correct |
79 |
Correct |
41 ms |
364 KB |
Output is correct |
80 |
Partially correct |
87 ms |
364 KB |
Partially correct - number of queries: 9582 |
81 |
Partially correct |
85 ms |
364 KB |
Partially correct - number of queries: 9584 |
82 |
Partially correct |
116 ms |
364 KB |
Partially correct - number of queries: 9514 |
83 |
Correct |
5 ms |
364 KB |
Output is correct |
84 |
Partially correct |
80 ms |
492 KB |
Partially correct - number of queries: 7942 |
85 |
Partially correct |
74 ms |
364 KB |
Partially correct - number of queries: 9618 |
86 |
Correct |
6 ms |
364 KB |
Output is correct |
87 |
Correct |
5 ms |
364 KB |
Output is correct |
88 |
Correct |
6 ms |
364 KB |
Output is correct |
89 |
Correct |
6 ms |
364 KB |
Output is correct |
90 |
Correct |
6 ms |
364 KB |
Output is correct |
91 |
Correct |
7 ms |
364 KB |
Output is correct |
92 |
Correct |
5 ms |
364 KB |
Output is correct |
93 |
Correct |
12 ms |
364 KB |
Output is correct |
94 |
Correct |
6 ms |
384 KB |
Output is correct |
95 |
Correct |
12 ms |
364 KB |
Output is correct |
96 |
Correct |
10 ms |
364 KB |
Output is correct |
97 |
Correct |
8 ms |
364 KB |
Output is correct |