Submission #73256

# Submission time Handle Problem Language Result Execution time Memory
73256 2018-08-28T06:02:57 Z Navick The Big Prize (IOI17_prize) C++17
97.66 / 100
67 ms 572 KB
#include <bits/stdc++.h>
#include "prize.h"

#define F first
#define S second
#define pii pair<int, int>
#define pb push_back

using namespace std;

typedef long long ll;

const int maxN = 475;

int p = -1, ted;

void solve(int l, int r, int k, int kl, int kr)
{
	if(r - l <= 0) return ;
	if(k == 0) return ;
	if(p != -1) return ;

	if(r - l < 2)
	{
		if(l < maxN) return ;
		vector <int> t = ask(l);
		if(t[0] + t[1] == 0) p = l;
		return ;
	}

	int mid = (l + r)/2;

	int i = mid, cnt = 0;
	bool ok = false;

	while(i < r)
	{
		vector <int> t = ask(i);
		if(t[0] + t[1] < ted){
			if(t[0] + t[1] == 0) p = i;
			i ++;
			cnt ++;
		}else
		{
			int a = t[0], b = t[1];
			a -= kl; a -= cnt;
			solve(l, mid, a, kl, cnt + t[1]);
			solve(i + 1, r, b - kr, t[0], kr);
			ok = true;
			break ;
		}
	}
	
	if(ok) return ;
	
	solve(l, mid, k - cnt, kl, cnt + kr);

	return ;

}

int find_best(int n) {
	
	int umax = 0;

	for(int i = 0; i < min(maxN, n); i++) {
		vector<int> res = ask(i);
		if(res[0] + res[1] == 0)
			return i;
		if(ted < res[0] + res[1]) {
			umax = i;
			ted = res[0] + res[1];
		}else if(ted > res[0] + res[1]) umax ++;
	}

	solve(maxN, n, ted - umax, umax, 0);

	return p;
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 248 KB Output is correct
2 Correct 8 ms 328 KB Output is correct
3 Correct 8 ms 328 KB Output is correct
4 Correct 9 ms 492 KB Output is correct
5 Correct 8 ms 492 KB Output is correct
6 Correct 3 ms 492 KB Output is correct
7 Correct 9 ms 508 KB Output is correct
8 Correct 9 ms 508 KB Output is correct
9 Correct 9 ms 528 KB Output is correct
10 Correct 7 ms 528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 556 KB Output is correct
2 Correct 5 ms 556 KB Output is correct
3 Correct 6 ms 556 KB Output is correct
4 Correct 6 ms 556 KB Output is correct
5 Correct 7 ms 556 KB Output is correct
6 Correct 2 ms 556 KB Output is correct
7 Correct 7 ms 556 KB Output is correct
8 Correct 4 ms 556 KB Output is correct
9 Correct 4 ms 572 KB Output is correct
10 Correct 6 ms 572 KB Output is correct
11 Correct 11 ms 572 KB Output is correct
12 Correct 11 ms 572 KB Output is correct
13 Correct 16 ms 572 KB Output is correct
14 Correct 7 ms 572 KB Output is correct
15 Correct 15 ms 572 KB Output is correct
16 Correct 35 ms 572 KB Output is correct
17 Correct 7 ms 572 KB Output is correct
18 Correct 23 ms 572 KB Output is correct
19 Correct 12 ms 572 KB Output is correct
20 Correct 26 ms 572 KB Output is correct
21 Correct 23 ms 572 KB Output is correct
22 Correct 18 ms 572 KB Output is correct
23 Correct 8 ms 572 KB Output is correct
24 Correct 8 ms 572 KB Output is correct
25 Correct 12 ms 572 KB Output is correct
26 Correct 28 ms 572 KB Output is correct
27 Correct 4 ms 572 KB Output is correct
28 Correct 43 ms 572 KB Output is correct
29 Correct 48 ms 572 KB Output is correct
30 Correct 59 ms 572 KB Output is correct
31 Correct 5 ms 572 KB Output is correct
32 Correct 12 ms 572 KB Output is correct
33 Correct 3 ms 572 KB Output is correct
34 Correct 11 ms 572 KB Output is correct
35 Correct 8 ms 572 KB Output is correct
36 Correct 22 ms 572 KB Output is correct
37 Correct 10 ms 572 KB Output is correct
38 Correct 5 ms 572 KB Output is correct
39 Correct 41 ms 572 KB Output is correct
40 Correct 46 ms 572 KB Output is correct
41 Correct 42 ms 572 KB Output is correct
42 Correct 38 ms 572 KB Output is correct
43 Correct 50 ms 572 KB Output is correct
44 Correct 22 ms 572 KB Output is correct
45 Correct 27 ms 572 KB Output is correct
46 Correct 8 ms 572 KB Output is correct
47 Correct 34 ms 572 KB Output is correct
48 Correct 40 ms 572 KB Output is correct
49 Correct 9 ms 572 KB Output is correct
50 Correct 20 ms 572 KB Output is correct
51 Correct 27 ms 572 KB Output is correct
52 Correct 10 ms 572 KB Output is correct
53 Correct 7 ms 572 KB Output is correct
54 Correct 30 ms 572 KB Output is correct
55 Correct 7 ms 572 KB Output is correct
56 Correct 62 ms 572 KB Output is correct
57 Correct 42 ms 572 KB Output is correct
58 Correct 30 ms 572 KB Output is correct
59 Correct 31 ms 572 KB Output is correct
60 Correct 25 ms 572 KB Output is correct
61 Correct 11 ms 572 KB Output is correct
62 Correct 8 ms 572 KB Output is correct
63 Correct 7 ms 572 KB Output is correct
64 Correct 9 ms 572 KB Output is correct
65 Correct 6 ms 572 KB Output is correct
66 Correct 11 ms 572 KB Output is correct
67 Correct 10 ms 572 KB Output is correct
68 Correct 7 ms 572 KB Output is correct
69 Correct 11 ms 572 KB Output is correct
70 Correct 10 ms 572 KB Output is correct
71 Partially correct 44 ms 572 KB Partially correct - number of queries: 5234
72 Correct 12 ms 572 KB Output is correct
73 Partially correct 32 ms 572 KB Partially correct - number of queries: 5171
74 Partially correct 23 ms 572 KB Partially correct - number of queries: 5198
75 Correct 9 ms 572 KB Output is correct
76 Correct 54 ms 572 KB Output is correct
77 Correct 44 ms 572 KB Output is correct
78 Correct 6 ms 572 KB Output is correct
79 Correct 26 ms 572 KB Output is correct
80 Correct 50 ms 572 KB Output is correct
81 Correct 38 ms 572 KB Output is correct
82 Correct 67 ms 572 KB Output is correct
83 Correct 8 ms 572 KB Output is correct
84 Correct 56 ms 572 KB Output is correct
85 Correct 41 ms 572 KB Output is correct
86 Correct 7 ms 572 KB Output is correct
87 Correct 6 ms 572 KB Output is correct
88 Correct 6 ms 572 KB Output is correct
89 Correct 6 ms 572 KB Output is correct
90 Correct 4 ms 572 KB Output is correct
91 Correct 5 ms 572 KB Output is correct
92 Correct 6 ms 572 KB Output is correct
93 Correct 5 ms 572 KB Output is correct
94 Correct 13 ms 572 KB Output is correct
95 Correct 8 ms 572 KB Output is correct
96 Correct 7 ms 572 KB Output is correct
97 Correct 4 ms 572 KB Output is correct