Submission #423286

# Submission time Handle Problem Language Result Execution time Memory
423286 2021-06-10T22:23:59 Z albertolg101 The Big Prize (IOI17_prize) C++17
90 / 100
105 ms 5392 KB
#include <bits/stdc++.h>
#include "prize.h"

using namespace std; 

int find_best(int n) {

	int sum = 0, pos = -1;
	vector<int> ar;
	
	int k = 500;

	for(int i = 0 ; i < k ; i++)
	{
		ar = ask(i);

		if(ar[0] + ar[1] == 0)
			return i;

		sum = max(sum, ar[0] + ar[1]);
	}

	pos = k - 1;

	while(true)
	{
		pos++;
		ar = ask(pos);
		if(ar[0] + ar[1] == 0)
			return pos;

		if(ar[0] + ar[1] == sum)
			break;
	}

	vector<vector<int>> query(n);

	function<vector<int>(int)> f = [&](int x)
	{
		if(query[x].empty())
			query[x] = ask(x);

		return query[x];
	};

	function<bool(int, int)> rng = [&](int l, int r)
	{
		f(l), f(r);

		if(query[l][0] + query[l][1] == query[r][0] + query[r][1] and query[l][0] + query[l][1] == sum and 0 == query[r][0] - query[l][0])
			return false;
		
		return true;
	};

	function<int(int, int)> dandc = [&](int l, int r)
	{
		if(l == r)
			return (query[l][0] + query[r][1] == 0 ? l : -1);

		int mid = (l + r) / 2, ans = -1;

		if(rng(l, mid))
			ans = max(ans, dandc(l, mid));

		if(rng(mid+1, r))
			ans = max(ans, dandc(mid+1, r));

		return ans;
	};

	return dandc(pos, n-1);
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 4880 KB Output is correct
2 Correct 8 ms 4928 KB Output is correct
3 Correct 8 ms 4928 KB Output is correct
4 Correct 9 ms 4928 KB Output is correct
5 Correct 10 ms 5000 KB Output is correct
6 Correct 1 ms 200 KB Output is correct
7 Correct 8 ms 4928 KB Output is correct
8 Correct 10 ms 4892 KB Output is correct
9 Correct 9 ms 4940 KB Output is correct
10 Correct 9 ms 4888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 4892 KB Output is correct
2 Correct 9 ms 4928 KB Output is correct
3 Correct 8 ms 4884 KB Output is correct
4 Correct 9 ms 4936 KB Output is correct
5 Correct 8 ms 4928 KB Output is correct
6 Correct 1 ms 284 KB Output is correct
7 Correct 12 ms 4928 KB Output is correct
8 Correct 8 ms 4876 KB Output is correct
9 Correct 8 ms 4936 KB Output is correct
10 Correct 6 ms 4936 KB Output is correct
11 Correct 9 ms 5008 KB Output is correct
12 Correct 18 ms 4876 KB Output is correct
13 Correct 19 ms 4928 KB Output is correct
14 Correct 27 ms 796 KB Output is correct
15 Partially correct 76 ms 5116 KB Partially correct - number of queries: 8243
16 Partially correct 95 ms 5392 KB Partially correct - number of queries: 8613
17 Correct 5 ms 200 KB Output is correct
18 Partially correct 105 ms 5196 KB Partially correct - number of queries: 8611
19 Correct 3 ms 280 KB Output is correct
20 Partially correct 29 ms 2808 KB Partially correct - number of queries: 5745
21 Partially correct 97 ms 5172 KB Partially correct - number of queries: 8552
22 Partially correct 79 ms 5064 KB Partially correct - number of queries: 6751
23 Correct 12 ms 4928 KB Output is correct
24 Correct 17 ms 5140 KB Output is correct
25 Partially correct 94 ms 5284 KB Partially correct - number of queries: 7808
26 Partially correct 77 ms 5392 KB Partially correct - number of queries: 7865
27 Correct 15 ms 4888 KB Output is correct
28 Partially correct 73 ms 5184 KB Partially correct - number of queries: 7803
29 Partially correct 66 ms 5132 KB Partially correct - number of queries: 6645
30 Partially correct 56 ms 5240 KB Partially correct - number of queries: 8557
31 Correct 6 ms 200 KB Output is correct
32 Correct 14 ms 4900 KB Output is correct
33 Correct 1 ms 200 KB Output is correct
34 Partially correct 88 ms 5348 KB Partially correct - number of queries: 8618
35 Correct 12 ms 4880 KB Output is correct
36 Partially correct 58 ms 5272 KB Partially correct - number of queries: 8556
37 Correct 17 ms 4884 KB Output is correct
38 Correct 12 ms 4928 KB Output is correct
39 Partially correct 83 ms 5160 KB Partially correct - number of queries: 8555
40 Partially correct 79 ms 5168 KB Partially correct - number of queries: 7531
41 Partially correct 88 ms 5248 KB Partially correct - number of queries: 8629
42 Partially correct 73 ms 5232 KB Partially correct - number of queries: 8629
43 Partially correct 103 ms 5204 KB Partially correct - number of queries: 8389
44 Partially correct 105 ms 5192 KB Partially correct - number of queries: 8618
45 Partially correct 86 ms 5184 KB Partially correct - number of queries: 7761
46 Correct 3 ms 284 KB Output is correct
47 Partially correct 67 ms 5136 KB Partially correct - number of queries: 7832
48 Partially correct 82 ms 5112 KB Partially correct - number of queries: 8618
49 Partially correct 83 ms 5136 KB Partially correct - number of queries: 8623
50 Partially correct 44 ms 5284 KB Partially correct - number of queries: 8612
51 Partially correct 70 ms 5228 KB Partially correct - number of queries: 8615
52 Partially correct 76 ms 5224 KB Partially correct - number of queries: 8613
53 Correct 9 ms 4892 KB Output is correct
54 Partially correct 89 ms 5212 KB Partially correct - number of queries: 8558
55 Correct 4 ms 200 KB Output is correct
56 Partially correct 85 ms 5180 KB Partially correct - number of queries: 8619
57 Partially correct 92 ms 5248 KB Partially correct - number of queries: 8556
58 Partially correct 94 ms 5184 KB Partially correct - number of queries: 8607
59 Partially correct 50 ms 5348 KB Partially correct - number of queries: 8629
60 Partially correct 105 ms 5136 KB Partially correct - number of queries: 8560
61 Correct 11 ms 4880 KB Output is correct
62 Correct 10 ms 4936 KB Output is correct
63 Correct 10 ms 4928 KB Output is correct
64 Correct 11 ms 4928 KB Output is correct
65 Correct 10 ms 4884 KB Output is correct
66 Correct 11 ms 4928 KB Output is correct
67 Correct 8 ms 4976 KB Output is correct
68 Correct 6 ms 200 KB Output is correct
69 Correct 13 ms 4928 KB Output is correct
70 Correct 12 ms 4888 KB Output is correct
71 Partially correct 90 ms 5144 KB Partially correct - number of queries: 8605
72 Correct 15 ms 5260 KB Output is correct
73 Partially correct 71 ms 5304 KB Partially correct - number of queries: 8500
74 Partially correct 99 ms 5140 KB Partially correct - number of queries: 8545
75 Correct 10 ms 4896 KB Output is correct
76 Partially correct 81 ms 5292 KB Partially correct - number of queries: 7525
77 Partially correct 104 ms 5184 KB Partially correct - number of queries: 8610
78 Correct 14 ms 4996 KB Output is correct
79 Correct 58 ms 5012 KB Output is correct
80 Partially correct 79 ms 5104 KB Partially correct - number of queries: 8596
81 Partially correct 76 ms 5132 KB Partially correct - number of queries: 8608
82 Partially correct 79 ms 5136 KB Partially correct - number of queries: 8521
83 Correct 9 ms 4936 KB Output is correct
84 Partially correct 72 ms 5104 KB Partially correct - number of queries: 7264
85 Partially correct 81 ms 5184 KB Partially correct - number of queries: 8565
86 Correct 9 ms 4936 KB Output is correct
87 Correct 9 ms 4900 KB Output is correct
88 Correct 8 ms 4936 KB Output is correct
89 Correct 5 ms 4896 KB Output is correct
90 Correct 12 ms 4900 KB Output is correct
91 Correct 9 ms 4900 KB Output is correct
92 Correct 8 ms 4936 KB Output is correct
93 Correct 14 ms 4936 KB Output is correct
94 Correct 11 ms 4936 KB Output is correct
95 Correct 16 ms 5056 KB Output is correct
96 Correct 12 ms 5016 KB Output is correct
97 Correct 7 ms 4936 KB Output is correct