#include "prize.h"
#include <assert.h>
#include <iostream>
#include <cmath>
using namespace std;
int N,S,K;
vector<int> A;
vector<int> M[200005];
int calls;
vector<int> vuoto(2,-1);
vector<int> q(int k){
if(k==-1){
vector<int> r(2,0);
r[1]=S;
return r;
}
if(M[k]==vuoto){
calls++;
if(calls==10000)
assert(false);
M[k]=ask(k);
}
//cout<<"q("<<k<<")="<<M[k][0]<<","<<M[k][1]<<endl;
return M[k];
}
int sinistra(int k){
int y=k;
vector<int> V;
int res=0;
V=q(k);
while(V[0]+V[1]!=S){
res++;
V=q(--k);
}
//cout<<"sinistra("<<y<<")="<<res+V[0]<<endl;
return res+V[0];
}
int find_best(int n) {
N=n;
fill(M,M+N,vuoto);
for(int i=0;i<min(N,500);i++){
A=q(i);
S=max(S,A[0]+A[1]);
if(S>(int)sqrt(N))
break;
}
while(K<S){
int l=0,r=N,m;
while(l<r){
m=(l+r)/2;
if(sinistra(m)<=K)
l=m+1;
else
r=m;
}
K++;
A=q(l);
if(A[0]==0 and A[1]==0)
return l;
}
}
Compilation message
prize.cpp: In function 'int sinistra(int)':
prize.cpp:34:9: warning: unused variable 'y' [-Wunused-variable]
int y=k;
^
prize.cpp: In function 'int find_best(int)':
prize.cpp:80:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
11172 KB |
Output is correct |
2 |
Correct |
32 ms |
11316 KB |
Output is correct |
3 |
Correct |
32 ms |
11316 KB |
Output is correct |
4 |
Correct |
28 ms |
11392 KB |
Output is correct |
5 |
Correct |
27 ms |
11392 KB |
Output is correct |
6 |
Correct |
25 ms |
11472 KB |
Output is correct |
7 |
Correct |
30 ms |
11472 KB |
Output is correct |
8 |
Correct |
36 ms |
11472 KB |
Output is correct |
9 |
Correct |
38 ms |
11472 KB |
Output is correct |
10 |
Correct |
28 ms |
11472 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
11472 KB |
Output is correct |
2 |
Correct |
29 ms |
11472 KB |
Output is correct |
3 |
Correct |
31 ms |
11472 KB |
Output is correct |
4 |
Correct |
30 ms |
11472 KB |
Output is correct |
5 |
Correct |
25 ms |
11472 KB |
Output is correct |
6 |
Correct |
26 ms |
11472 KB |
Output is correct |
7 |
Correct |
26 ms |
11472 KB |
Output is correct |
8 |
Correct |
31 ms |
11472 KB |
Output is correct |
9 |
Correct |
25 ms |
11472 KB |
Output is correct |
10 |
Correct |
28 ms |
11472 KB |
Output is correct |
11 |
Correct |
29 ms |
11472 KB |
Output is correct |
12 |
Correct |
36 ms |
11472 KB |
Output is correct |
13 |
Correct |
33 ms |
11472 KB |
Output is correct |
14 |
Correct |
13 ms |
11472 KB |
Output is correct |
15 |
Correct |
28 ms |
11472 KB |
Output is correct |
16 |
Correct |
58 ms |
11472 KB |
Output is correct |
17 |
Correct |
24 ms |
11472 KB |
Output is correct |
18 |
Correct |
70 ms |
11472 KB |
Output is correct |
19 |
Correct |
29 ms |
11472 KB |
Output is correct |
20 |
Correct |
28 ms |
11472 KB |
Output is correct |
21 |
Correct |
43 ms |
11472 KB |
Output is correct |
22 |
Correct |
27 ms |
11472 KB |
Output is correct |
23 |
Correct |
29 ms |
11472 KB |
Output is correct |
24 |
Correct |
32 ms |
11472 KB |
Output is correct |
25 |
Correct |
35 ms |
11472 KB |
Output is correct |
26 |
Correct |
58 ms |
11472 KB |
Output is correct |
27 |
Correct |
27 ms |
11528 KB |
Output is correct |
28 |
Correct |
44 ms |
11528 KB |
Output is correct |
29 |
Correct |
47 ms |
11528 KB |
Output is correct |
30 |
Correct |
81 ms |
11528 KB |
Output is correct |
31 |
Correct |
25 ms |
11528 KB |
Output is correct |
32 |
Correct |
32 ms |
11528 KB |
Output is correct |
33 |
Correct |
7 ms |
11528 KB |
Output is correct |
34 |
Correct |
36 ms |
11528 KB |
Output is correct |
35 |
Correct |
28 ms |
11528 KB |
Output is correct |
36 |
Correct |
34 ms |
11528 KB |
Output is correct |
37 |
Correct |
30 ms |
11528 KB |
Output is correct |
38 |
Correct |
28 ms |
11528 KB |
Output is correct |
39 |
Correct |
41 ms |
11528 KB |
Output is correct |
40 |
Correct |
49 ms |
11528 KB |
Output is correct |
41 |
Correct |
35 ms |
11528 KB |
Output is correct |
42 |
Correct |
46 ms |
11528 KB |
Output is correct |
43 |
Correct |
56 ms |
11528 KB |
Output is correct |
44 |
Correct |
51 ms |
11528 KB |
Output is correct |
45 |
Correct |
40 ms |
11528 KB |
Output is correct |
46 |
Correct |
25 ms |
11528 KB |
Output is correct |
47 |
Correct |
41 ms |
11528 KB |
Output is correct |
48 |
Correct |
54 ms |
11528 KB |
Output is correct |
49 |
Correct |
34 ms |
11528 KB |
Output is correct |
50 |
Correct |
65 ms |
11528 KB |
Output is correct |
51 |
Correct |
30 ms |
11528 KB |
Output is correct |
52 |
Correct |
27 ms |
11528 KB |
Output is correct |
53 |
Correct |
22 ms |
11528 KB |
Output is correct |
54 |
Correct |
49 ms |
11528 KB |
Output is correct |
55 |
Correct |
22 ms |
11528 KB |
Output is correct |
56 |
Correct |
74 ms |
11528 KB |
Output is correct |
57 |
Correct |
53 ms |
11528 KB |
Output is correct |
58 |
Correct |
64 ms |
11528 KB |
Output is correct |
59 |
Correct |
60 ms |
11528 KB |
Output is correct |
60 |
Correct |
55 ms |
11580 KB |
Output is correct |
61 |
Correct |
26 ms |
11580 KB |
Output is correct |
62 |
Correct |
25 ms |
11580 KB |
Output is correct |
63 |
Correct |
26 ms |
11580 KB |
Output is correct |
64 |
Correct |
25 ms |
11580 KB |
Output is correct |
65 |
Correct |
29 ms |
11580 KB |
Output is correct |
66 |
Correct |
81 ms |
11580 KB |
Output is correct |
67 |
Correct |
23 ms |
11580 KB |
Output is correct |
68 |
Correct |
74 ms |
11580 KB |
Output is correct |
69 |
Correct |
92 ms |
11580 KB |
Output is correct |
70 |
Correct |
27 ms |
11580 KB |
Output is correct |
71 |
Correct |
67 ms |
11580 KB |
Output is correct |
72 |
Correct |
34 ms |
11580 KB |
Output is correct |
73 |
Correct |
77 ms |
11580 KB |
Output is correct |
74 |
Correct |
85 ms |
11580 KB |
Output is correct |
75 |
Correct |
38 ms |
11580 KB |
Output is correct |
76 |
Correct |
64 ms |
11580 KB |
Output is correct |
77 |
Correct |
65 ms |
11580 KB |
Output is correct |
78 |
Correct |
31 ms |
11580 KB |
Output is correct |
79 |
Correct |
49 ms |
11580 KB |
Output is correct |
80 |
Correct |
43 ms |
11580 KB |
Output is correct |
81 |
Correct |
83 ms |
11580 KB |
Output is correct |
82 |
Correct |
68 ms |
11580 KB |
Output is correct |
83 |
Correct |
32 ms |
11580 KB |
Output is correct |
84 |
Correct |
73 ms |
11580 KB |
Output is correct |
85 |
Correct |
76 ms |
11580 KB |
Output is correct |
86 |
Correct |
84 ms |
11580 KB |
Output is correct |
87 |
Correct |
39 ms |
11580 KB |
Output is correct |
88 |
Correct |
81 ms |
11580 KB |
Output is correct |
89 |
Correct |
89 ms |
11580 KB |
Output is correct |
90 |
Correct |
26 ms |
11580 KB |
Output is correct |
91 |
Correct |
50 ms |
11580 KB |
Output is correct |
92 |
Correct |
73 ms |
11580 KB |
Output is correct |
93 |
Correct |
101 ms |
11580 KB |
Output is correct |
94 |
Correct |
91 ms |
11580 KB |
Output is correct |
95 |
Correct |
81 ms |
11580 KB |
Output is correct |
96 |
Correct |
98 ms |
11580 KB |
Output is correct |
97 |
Correct |
91 ms |
11580 KB |
Output is correct |