Submission #292973

# Submission time Handle Problem Language Result Execution time Memory
292973 2020-09-07T15:13:18 Z luciocf The Big Prize (IOI17_prize) C++14
90 / 100
104 ms 384 KB
#include <bits/stdc++.h>
#include "prize.h"

#define ff first
#define ss second

using namespace std;

typedef pair<int, int> pii;

const int maxn = 2e5+10;

int qtd[10];
pii v[maxn];

pii get(int i)
{
	vector<int> v = ask(i);

	return {v[0], v[1]};
}

int find_best(int n)
{
	int ind = 0;
	for (int i = 0; i < min(n, 500); i++)
	{
		int v = get(i).ff+get(i).ss;

		if (v == 0) return i;

		if (v > qtd[1])
			qtd[1] = v, ind = i;
	}

	int ant = ind;
	pii v_ind = get(ind);

	for (int i = 1; i <= 500; i++)
	{
		int ini = ant+1, fim = n-1, ans;

		while (ini <= fim)
		{
			int mid = (ini+fim)/2;

			pii v = get(mid);

			if (v.ff+v.ss != qtd[1])
			{
				if (v.ff+v.ss == 0) return mid;

				ans = mid, fim = mid-1;
			}
			else if (v.ff-v_ind.ff-(i-1) > 0) fim = mid-1;
			else ini = mid+1;
		}

		ant = ans;
	}
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:61:1: warning: control reaches end of non-void function [-Wreturn-type]
   61 | }
      | ^
prize.cpp:41:7: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   41 |   int ini = ant+1, fim = n-1, ans;
      |       ^~~
# Verdict Execution time Memory Grader output
1 Correct 10 ms 368 KB Output is correct
2 Correct 6 ms 368 KB Output is correct
3 Correct 9 ms 256 KB Output is correct
4 Correct 10 ms 256 KB Output is correct
5 Correct 12 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 9 ms 364 KB Output is correct
8 Correct 11 ms 364 KB Output is correct
9 Correct 13 ms 256 KB Output is correct
10 Correct 9 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 372 KB Output is correct
2 Correct 13 ms 364 KB Output is correct
3 Correct 13 ms 256 KB Output is correct
4 Correct 14 ms 372 KB Output is correct
5 Correct 13 ms 376 KB Output is correct
6 Correct 1 ms 372 KB Output is correct
7 Correct 7 ms 376 KB Output is correct
8 Correct 13 ms 372 KB Output is correct
9 Correct 11 ms 364 KB Output is correct
10 Correct 11 ms 256 KB Output is correct
11 Correct 14 ms 256 KB Output is correct
12 Correct 15 ms 256 KB Output is correct
13 Correct 8 ms 360 KB Output is correct
14 Correct 13 ms 256 KB Output is correct
15 Correct 20 ms 368 KB Output is correct
16 Partially correct 67 ms 256 KB Partially correct - number of queries: 7549
17 Correct 9 ms 256 KB Output is correct
18 Partially correct 59 ms 368 KB Partially correct - number of queries: 8665
19 Correct 5 ms 376 KB Output is correct
20 Correct 23 ms 384 KB Output is correct
21 Correct 36 ms 372 KB Output is correct
22 Correct 20 ms 256 KB Output is correct
23 Correct 6 ms 368 KB Output is correct
24 Correct 10 ms 256 KB Output is correct
25 Partially correct 29 ms 368 KB Partially correct - number of queries: 5376
26 Partially correct 49 ms 256 KB Partially correct - number of queries: 5339
27 Correct 13 ms 256 KB Output is correct
28 Partially correct 101 ms 256 KB Partially correct - number of queries: 8323
29 Partially correct 35 ms 256 KB Partially correct - number of queries: 6545
30 Partially correct 85 ms 256 KB Partially correct - number of queries: 8601
31 Correct 12 ms 256 KB Output is correct
32 Correct 9 ms 256 KB Output is correct
33 Correct 0 ms 256 KB Output is correct
34 Correct 34 ms 288 KB Output is correct
35 Correct 6 ms 364 KB Output is correct
36 Correct 22 ms 384 KB Output is correct
37 Correct 15 ms 368 KB Output is correct
38 Correct 12 ms 256 KB Output is correct
39 Correct 37 ms 256 KB Output is correct
40 Partially correct 60 ms 256 KB Partially correct - number of queries: 7490
41 Partially correct 61 ms 384 KB Partially correct - number of queries: 5610
42 Partially correct 65 ms 256 KB Partially correct - number of queries: 5610
43 Partially correct 38 ms 368 KB Partially correct - number of queries: 5163
44 Correct 51 ms 364 KB Output is correct
45 Correct 45 ms 256 KB Output is correct
46 Correct 5 ms 368 KB Output is correct
47 Correct 60 ms 372 KB Output is correct
48 Partially correct 54 ms 256 KB Partially correct - number of queries: 6689
49 Correct 9 ms 360 KB Output is correct
50 Partially correct 104 ms 256 KB Partially correct - number of queries: 8654
51 Correct 33 ms 256 KB Output is correct
52 Correct 9 ms 364 KB Output is correct
53 Correct 16 ms 256 KB Output is correct
54 Correct 45 ms 256 KB Output is correct
55 Correct 11 ms 256 KB Output is correct
56 Partially correct 84 ms 384 KB Partially correct - number of queries: 8662
57 Partially correct 35 ms 376 KB Partially correct - number of queries: 6612
58 Partially correct 85 ms 256 KB Partially correct - number of queries: 6707
59 Partially correct 49 ms 360 KB Partially correct - number of queries: 5610
60 Partially correct 27 ms 380 KB Partially correct - number of queries: 5277
61 Correct 14 ms 256 KB Output is correct
62 Correct 15 ms 256 KB Output is correct
63 Correct 6 ms 380 KB Output is correct
64 Correct 10 ms 256 KB Output is correct
65 Correct 10 ms 256 KB Output is correct
66 Correct 53 ms 256 KB Output is correct
67 Correct 12 ms 256 KB Output is correct
68 Correct 11 ms 256 KB Output is correct
69 Correct 38 ms 256 KB Output is correct
70 Correct 6 ms 288 KB Output is correct
71 Partially correct 100 ms 256 KB Partially correct - number of queries: 8801
72 Correct 16 ms 256 KB Output is correct
73 Partially correct 101 ms 256 KB Partially correct - number of queries: 8696
74 Partially correct 80 ms 320 KB Partially correct - number of queries: 8751
75 Correct 10 ms 256 KB Output is correct
76 Partially correct 69 ms 256 KB Partially correct - number of queries: 7623
77 Partially correct 104 ms 256 KB Partially correct - number of queries: 8666
78 Correct 19 ms 256 KB Output is correct
79 Correct 48 ms 360 KB Output is correct
80 Partially correct 62 ms 256 KB Partially correct - number of queries: 8662
81 Partially correct 103 ms 256 KB Partially correct - number of queries: 8653
82 Partially correct 76 ms 256 KB Partially correct - number of queries: 8603
83 Correct 11 ms 256 KB Output is correct
84 Partially correct 71 ms 256 KB Partially correct - number of queries: 7286
85 Partially correct 83 ms 256 KB Partially correct - number of queries: 8713
86 Correct 10 ms 256 KB Output is correct
87 Correct 9 ms 256 KB Output is correct
88 Correct 8 ms 256 KB Output is correct
89 Correct 9 ms 256 KB Output is correct
90 Correct 9 ms 256 KB Output is correct
91 Correct 12 ms 256 KB Output is correct
92 Correct 11 ms 256 KB Output is correct
93 Correct 12 ms 256 KB Output is correct
94 Correct 13 ms 256 KB Output is correct
95 Correct 11 ms 256 KB Output is correct
96 Correct 13 ms 256 KB Output is correct
97 Correct 11 ms 288 KB Output is correct