Submission #390478

# Submission time Handle Problem Language Result Execution time Memory
390478 2021-04-16T06:45:58 Z Keshi The Big Prize (IOI17_prize) C++17
93.09 / 100
73 ms 572 KB
//In the name of God
#include <bits/stdc++.h>
#include "prize.h"
using namespace std;

typedef int ll;
typedef pair<ll, ll> pll;

const ll maxn = 2e5 + 100;
const ll mod = 1e9 + 7;
const ll inf = 1e9;

#define pb push_back
#define Mp make_pair
#define F first
#define S second
#define Sz(x) ll((x).size())
#define all(x) (x).begin(), (x).end()

vector<pair<ll, pll> > vec;

int find_best(int n){
	ll p = n / 500 + 1;

	ll x = 0;
	for(ll i = 0; i < n; i += p){
		auto f = ask(i);
		vec.pb(Mp(i, Mp(f[0], f[1])));
		x = max(x, f[0] + f[1]);
	}
	ll ptr = 0;
	while(ptr < n){
		auto f = ask(ptr);
		vec.pb(Mp(ptr, Mp(f[0], f[1])));
		if(f[0] + f[1] == 0) return ptr;
		if(f[0] + f[1] != x){
			ptr++;
			continue;
		}
		ll l = ptr, r = n;
		for(auto i : vec){
			if(i.F < ptr) continue;
			if(i.S.F == f[0] && i.S.S == f[1]) l = max(l, i.F);
			else r = min(r, i.F);
		}
		while(r - l > 1){
			ll mid = (l + r) >> 1;
			auto f2 = ask(mid);
			vec.pb(Mp(mid, Mp(f2[0], f2[1])));
			if(f2[0] == f[0] && f2[1] == f[1]) l = mid;
			else r = mid;
		}
		ptr = r;
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 300 KB Output is correct
2 Correct 8 ms 284 KB Output is correct
3 Correct 8 ms 200 KB Output is correct
4 Correct 3 ms 328 KB Output is correct
5 Correct 6 ms 200 KB Output is correct
6 Correct 3 ms 296 KB Output is correct
7 Correct 7 ms 200 KB Output is correct
8 Correct 7 ms 288 KB Output is correct
9 Correct 8 ms 300 KB Output is correct
10 Correct 4 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 280 KB Output is correct
2 Correct 7 ms 276 KB Output is correct
3 Correct 3 ms 336 KB Output is correct
4 Correct 3 ms 296 KB Output is correct
5 Correct 5 ms 288 KB Output is correct
6 Correct 6 ms 292 KB Output is correct
7 Correct 7 ms 200 KB Output is correct
8 Correct 3 ms 380 KB Output is correct
9 Correct 3 ms 336 KB Output is correct
10 Correct 7 ms 304 KB Output is correct
11 Correct 5 ms 200 KB Output is correct
12 Correct 7 ms 264 KB Output is correct
13 Correct 12 ms 200 KB Output is correct
14 Correct 7 ms 200 KB Output is correct
15 Correct 17 ms 200 KB Output is correct
16 Correct 23 ms 424 KB Output is correct
17 Correct 7 ms 280 KB Output is correct
18 Partially correct 29 ms 572 KB Partially correct - number of queries: 5571
19 Correct 3 ms 284 KB Output is correct
20 Correct 22 ms 312 KB Output is correct
21 Correct 28 ms 284 KB Output is correct
22 Correct 4 ms 328 KB Output is correct
23 Correct 5 ms 200 KB Output is correct
24 Correct 10 ms 284 KB Output is correct
25 Correct 15 ms 412 KB Output is correct
26 Correct 15 ms 360 KB Output is correct
27 Correct 10 ms 288 KB Output is correct
28 Correct 50 ms 556 KB Output is correct
29 Correct 37 ms 320 KB Output is correct
30 Partially correct 32 ms 376 KB Partially correct - number of queries: 5521
31 Correct 4 ms 280 KB Output is correct
32 Correct 8 ms 332 KB Output is correct
33 Correct 1 ms 200 KB Output is correct
34 Correct 10 ms 324 KB Output is correct
35 Correct 9 ms 288 KB Output is correct
36 Correct 26 ms 320 KB Output is correct
37 Correct 5 ms 280 KB Output is correct
38 Correct 7 ms 288 KB Output is correct
39 Correct 32 ms 320 KB Output is correct
40 Correct 60 ms 368 KB Output is correct
41 Correct 36 ms 320 KB Output is correct
42 Correct 18 ms 412 KB Output is correct
43 Correct 15 ms 360 KB Output is correct
44 Correct 34 ms 292 KB Output is correct
45 Correct 22 ms 320 KB Output is correct
46 Correct 4 ms 200 KB Output is correct
47 Correct 13 ms 356 KB Output is correct
48 Correct 20 ms 428 KB Output is correct
49 Correct 9 ms 300 KB Output is correct
50 Partially correct 73 ms 404 KB Partially correct - number of queries: 5549
51 Correct 35 ms 320 KB Output is correct
52 Correct 6 ms 288 KB Output is correct
53 Correct 6 ms 292 KB Output is correct
54 Correct 16 ms 412 KB Output is correct
55 Correct 4 ms 200 KB Output is correct
56 Partially correct 27 ms 444 KB Partially correct - number of queries: 5553
57 Correct 54 ms 320 KB Output is correct
58 Correct 50 ms 492 KB Output is correct
59 Correct 36 ms 320 KB Output is correct
60 Correct 15 ms 380 KB Output is correct
61 Correct 5 ms 292 KB Output is correct
62 Correct 5 ms 396 KB Output is correct
63 Correct 4 ms 288 KB Output is correct
64 Correct 8 ms 200 KB Output is correct
65 Correct 3 ms 300 KB Output is correct
66 Correct 13 ms 296 KB Output is correct
67 Correct 3 ms 328 KB Output is correct
68 Correct 13 ms 200 KB Output is correct
69 Correct 12 ms 268 KB Output is correct
70 Correct 9 ms 288 KB Output is correct
71 Partially correct 52 ms 356 KB Partially correct - number of queries: 5691
72 Correct 10 ms 200 KB Output is correct
73 Partially correct 36 ms 440 KB Partially correct - number of queries: 5614
74 Partially correct 65 ms 496 KB Partially correct - number of queries: 5647
75 Correct 7 ms 312 KB Output is correct
76 Correct 39 ms 328 KB Output is correct
77 Partially correct 44 ms 424 KB Partially correct - number of queries: 5691
78 Correct 11 ms 200 KB Output is correct
79 Correct 35 ms 300 KB Output is correct
80 Partially correct 61 ms 328 KB Partially correct - number of queries: 5686
81 Partially correct 59 ms 432 KB Partially correct - number of queries: 5681
82 Partially correct 27 ms 436 KB Partially correct - number of queries: 5647
83 Correct 8 ms 300 KB Output is correct
84 Correct 46 ms 320 KB Output is correct
85 Partially correct 29 ms 564 KB Partially correct - number of queries: 5674
86 Correct 54 ms 364 KB Output is correct
87 Correct 11 ms 200 KB Output is correct
88 Correct 36 ms 428 KB Output is correct
89 Correct 20 ms 344 KB Output is correct
90 Correct 6 ms 200 KB Output is correct
91 Correct 35 ms 320 KB Output is correct
92 Correct 20 ms 336 KB Output is correct
93 Partially correct 62 ms 444 KB Partially correct - number of queries: 5630
94 Partially correct 63 ms 424 KB Partially correct - number of queries: 5608
95 Partially correct 57 ms 516 KB Partially correct - number of queries: 5637
96 Partially correct 72 ms 328 KB Partially correct - number of queries: 5593
97 Partially correct 69 ms 424 KB Partially correct - number of queries: 5406