#include "prize.h"
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
typedef pair< vector<int>,vector<int> > PVV;
typedef pair< int,PVV > PIVV;
typedef pair< int,PIVV > PIIVV;
typedef pair< int,PIIVV > PIIIVV;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;
int n,m,b[li],a[li],k,flag,t;
int cev;
string s;
vector<int> v;
int find_best(int n) {
int bas=0;
int son=n-1;
priority_queue<PIIIVV> q;
vector<int> v1;
v=ask(0);
v1=ask(n-1);
q.push({(max(v[0],v1[0])+max(v[1],v1[1])),{bas,{son,{v,v1}}}});
while(q.size()){
bas=q.top().se.fi;
son=q.top().se.se.fi;
v=q.top().se.se.se.fi;
v1=q.top().se.se.se.se;
q.pop();
if(v[0]==v1[0] && v[1]==v1[1])continue;
if(bas>son)continue;
vector<int> res=ask(ort);
if(res[0]+res[1]==0)return ort;
q.push({(max(v[0],res[0])+max(v[1],res[1])),{bas,{ort-1,{v,res}}}});
q.push({(max(res[0],v1[0])+max(res[1],v1[1])),{ort+1,{son,{res,v1}}}});
}
return son;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
1 ms |
256 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Correct |
1 ms |
256 KB |
Output is correct |
9 |
Correct |
1 ms |
256 KB |
Output is correct |
10 |
Correct |
1 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Correct |
1 ms |
256 KB |
Output is correct |
9 |
Correct |
1 ms |
256 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
4 ms |
376 KB |
Output is correct |
12 |
Correct |
6 ms |
376 KB |
Output is correct |
13 |
Correct |
1 ms |
256 KB |
Output is correct |
14 |
Correct |
8 ms |
504 KB |
Output is correct |
15 |
Correct |
35 ms |
760 KB |
Output is correct |
16 |
Correct |
11 ms |
504 KB |
Output is correct |
17 |
Correct |
54 ms |
1128 KB |
Output is correct |
18 |
Correct |
6 ms |
384 KB |
Output is correct |
19 |
Correct |
47 ms |
868 KB |
Output is correct |
20 |
Correct |
20 ms |
632 KB |
Output is correct |
21 |
Correct |
19 ms |
800 KB |
Output is correct |
22 |
Correct |
29 ms |
760 KB |
Output is correct |
23 |
Correct |
2 ms |
384 KB |
Output is correct |
24 |
Correct |
6 ms |
384 KB |
Output is correct |
25 |
Correct |
26 ms |
760 KB |
Output is correct |
26 |
Correct |
25 ms |
760 KB |
Output is correct |
27 |
Correct |
2 ms |
384 KB |
Output is correct |
28 |
Correct |
12 ms |
504 KB |
Output is correct |
29 |
Correct |
12 ms |
384 KB |
Output is correct |
30 |
Correct |
6 ms |
376 KB |
Output is correct |
31 |
Correct |
42 ms |
1124 KB |
Output is correct |
32 |
Correct |
3 ms |
384 KB |
Output is correct |
33 |
Correct |
1 ms |
256 KB |
Output is correct |
34 |
Correct |
40 ms |
760 KB |
Output is correct |
35 |
Correct |
2 ms |
384 KB |
Output is correct |
36 |
Correct |
43 ms |
760 KB |
Output is correct |
37 |
Correct |
5 ms |
384 KB |
Output is correct |
38 |
Correct |
2 ms |
384 KB |
Output is correct |
39 |
Correct |
23 ms |
760 KB |
Output is correct |
40 |
Correct |
5 ms |
376 KB |
Output is correct |
41 |
Correct |
20 ms |
640 KB |
Output is correct |
42 |
Correct |
22 ms |
632 KB |
Output is correct |
43 |
Correct |
26 ms |
760 KB |
Output is correct |
44 |
Correct |
32 ms |
760 KB |
Output is correct |
45 |
Correct |
24 ms |
760 KB |
Output is correct |
46 |
Correct |
54 ms |
1124 KB |
Output is correct |
47 |
Correct |
23 ms |
760 KB |
Output is correct |
48 |
Correct |
22 ms |
512 KB |
Output is correct |
49 |
Correct |
51 ms |
868 KB |
Output is correct |
50 |
Correct |
6 ms |
376 KB |
Output is correct |
51 |
Correct |
28 ms |
760 KB |
Output is correct |
52 |
Correct |
45 ms |
1124 KB |
Output is correct |
53 |
Correct |
1 ms |
256 KB |
Output is correct |
54 |
Correct |
36 ms |
760 KB |
Output is correct |
55 |
Correct |
41 ms |
1124 KB |
Output is correct |
56 |
Correct |
6 ms |
376 KB |
Output is correct |
57 |
Correct |
20 ms |
508 KB |
Output is correct |
58 |
Correct |
54 ms |
776 KB |
Output is correct |
59 |
Correct |
21 ms |
636 KB |
Output is correct |
60 |
Correct |
28 ms |
760 KB |
Output is correct |
61 |
Correct |
1 ms |
256 KB |
Output is correct |
62 |
Correct |
2 ms |
384 KB |
Output is correct |
63 |
Correct |
1 ms |
360 KB |
Output is correct |
64 |
Correct |
2 ms |
368 KB |
Output is correct |
65 |
Correct |
1 ms |
376 KB |
Output is correct |
66 |
Correct |
1 ms |
256 KB |
Output is correct |
67 |
Correct |
1 ms |
256 KB |
Output is correct |
68 |
Correct |
1 ms |
256 KB |
Output is correct |
69 |
Correct |
1 ms |
364 KB |
Output is correct |
70 |
Correct |
1 ms |
368 KB |
Output is correct |
71 |
Correct |
49 ms |
1132 KB |
Output is correct |
72 |
Correct |
6 ms |
384 KB |
Output is correct |
73 |
Correct |
42 ms |
1152 KB |
Output is correct |
74 |
Correct |
52 ms |
1212 KB |
Output is correct |
75 |
Correct |
2 ms |
384 KB |
Output is correct |
76 |
Correct |
47 ms |
1168 KB |
Output is correct |
77 |
Correct |
56 ms |
1124 KB |
Output is correct |
78 |
Correct |
5 ms |
384 KB |
Output is correct |
79 |
Correct |
22 ms |
744 KB |
Output is correct |
80 |
Correct |
39 ms |
1148 KB |
Output is correct |
81 |
Correct |
48 ms |
1124 KB |
Output is correct |
82 |
Correct |
56 ms |
1136 KB |
Output is correct |
83 |
Correct |
2 ms |
368 KB |
Output is correct |
84 |
Correct |
45 ms |
764 KB |
Output is correct |
85 |
Correct |
47 ms |
1124 KB |
Output is correct |
86 |
Correct |
3 ms |
384 KB |
Output is correct |
87 |
Correct |
1 ms |
384 KB |
Output is correct |
88 |
Correct |
3 ms |
380 KB |
Output is correct |
89 |
Correct |
2 ms |
384 KB |
Output is correct |
90 |
Correct |
1 ms |
368 KB |
Output is correct |
91 |
Correct |
1 ms |
384 KB |
Output is correct |
92 |
Correct |
1 ms |
256 KB |
Output is correct |
93 |
Correct |
4 ms |
384 KB |
Output is correct |
94 |
Correct |
5 ms |
384 KB |
Output is correct |
95 |
Correct |
5 ms |
384 KB |
Output is correct |
96 |
Correct |
4 ms |
384 KB |
Output is correct |
97 |
Correct |
1 ms |
256 KB |
Output is correct |