Submission #104745

# Submission time Handle Problem Language Result Execution time Memory
104745 2019-04-09T04:08:22 Z turbat The Big Prize (IOI17_prize) C++14
90 / 100
66 ms 2128 KB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
using vi = vector <int>;
using pii = pair <int, int>;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define N 200005
map < int, vector<int> > query;
int mx;
int fen[N];
bool u[N];
void add(int x){
	x++;
	if (!u[x]) u[x] = 1;
	else return;
	while (x < N){
		fen[x]++;
		x += (x & (-x));
	}
}
int sum(int x){
	x++;
	int s = 0;
	while (x){
		s = s + fen[x];
		x -= (x & (-x));
	}
	return s;
}
vector < int > askk(int x){
	if( query.find( x ) == query.end() ){
		return query[x] = ask(x);
	}
	return query[x];
}
int gg(int l, int r){
	vi tmp;
	if (l > r) return -1;
	// cerr << l<<" " << r<< '\n';
	if (l == r) {
		tmp = askk(l);
		add(l);
		if (tmp[0] + tmp[1] == 0) return l;	
		return -1;
	}
	while(l <= r){
		tmp = askk(r);
		if ((tmp[0] + tmp[1]) == 0) {
			add(r);
			return r;
		}
		if (tmp[0] + tmp[1] == mx) break;
		add(r);
		r--;
	}
	// cerr <<tmp[1]<<" "<< tmp[0] <<" "<< sum(l - 1)<< " "<< l << " "<< r<< endl;
	if (l > r) return -1;
	if (tmp[0] == sum(l - 1)) return -1;
	if (l == r) return gg(l, r);
	int mid = (l + r) / 2;
	int ind = gg(l , mid);
	if (ind != -1) return ind;
	if (tmp[0] != sum(mid)) return gg(mid + 1, r - 1);
	return - 1;
}
int find_best(int n) {
	int s[505];
	for (int i = 0;i < 500;i++){
		vi ans = askk(i);
		s[i] = ans[0] + ans[1];
		if (!s[i]) return i;
		mx = max(mx, s[i]);
	}
	for (int i = 0;i < 500;i++)
		if (s[i] != mx)
			add(i);
	// cerr << sum(499)<< " "<< mx<< endl;
	return gg(500, n - 1);
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 568 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 7 ms 384 KB Output is correct
4 Correct 4 ms 420 KB Output is correct
5 Correct 4 ms 464 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 7 ms 376 KB Output is correct
8 Correct 9 ms 320 KB Output is correct
9 Correct 5 ms 568 KB Output is correct
10 Correct 7 ms 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 5 ms 488 KB Output is correct
3 Correct 4 ms 488 KB Output is correct
4 Correct 9 ms 384 KB Output is correct
5 Correct 7 ms 400 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 4 ms 464 KB Output is correct
9 Correct 5 ms 412 KB Output is correct
10 Correct 13 ms 380 KB Output is correct
11 Correct 9 ms 572 KB Output is correct
12 Correct 7 ms 376 KB Output is correct
13 Correct 13 ms 884 KB Output is correct
14 Correct 7 ms 384 KB Output is correct
15 Correct 9 ms 760 KB Output is correct
16 Partially correct 42 ms 1728 KB Partially correct - number of queries: 5345
17 Correct 7 ms 320 KB Output is correct
18 Partially correct 46 ms 1880 KB Partially correct - number of queries: 6413
19 Correct 6 ms 256 KB Output is correct
20 Correct 12 ms 712 KB Output is correct
21 Correct 29 ms 880 KB Output is correct
22 Correct 6 ms 512 KB Output is correct
23 Correct 4 ms 440 KB Output is correct
24 Correct 6 ms 376 KB Output is correct
25 Correct 28 ms 1312 KB Output is correct
26 Correct 25 ms 1180 KB Output is correct
27 Correct 9 ms 444 KB Output is correct
28 Partially correct 59 ms 1908 KB Partially correct - number of queries: 5484
29 Correct 40 ms 1580 KB Output is correct
30 Partially correct 58 ms 1912 KB Partially correct - number of queries: 6348
31 Correct 6 ms 384 KB Output is correct
32 Correct 12 ms 760 KB Output is correct
33 Correct 3 ms 384 KB Output is correct
34 Correct 21 ms 760 KB Output is correct
35 Correct 8 ms 504 KB Output is correct
36 Correct 10 ms 716 KB Output is correct
37 Correct 6 ms 504 KB Output is correct
38 Correct 4 ms 468 KB Output is correct
39 Correct 23 ms 1032 KB Output is correct
40 Partially correct 52 ms 1832 KB Partially correct - number of queries: 5653
41 Correct 33 ms 1212 KB Output is correct
42 Correct 41 ms 1212 KB Output is correct
43 Correct 30 ms 1240 KB Output is correct
44 Correct 19 ms 1036 KB Output is correct
45 Correct 13 ms 920 KB Output is correct
46 Correct 7 ms 256 KB Output is correct
47 Correct 24 ms 1040 KB Output is correct
48 Correct 22 ms 1568 KB Output is correct
49 Correct 13 ms 504 KB Output is correct
50 Partially correct 41 ms 1960 KB Partially correct - number of queries: 6376
51 Correct 27 ms 908 KB Output is correct
52 Correct 7 ms 376 KB Output is correct
53 Correct 5 ms 508 KB Output is correct
54 Correct 27 ms 1016 KB Output is correct
55 Correct 5 ms 256 KB Output is correct
56 Partially correct 66 ms 1992 KB Partially correct - number of queries: 6411
57 Correct 42 ms 1480 KB Output is correct
58 Correct 47 ms 1600 KB Output is correct
59 Correct 39 ms 1272 KB Output is correct
60 Correct 36 ms 1144 KB Output is correct
61 Correct 8 ms 504 KB Output is correct
62 Correct 4 ms 448 KB Output is correct
63 Correct 5 ms 568 KB Output is correct
64 Correct 9 ms 504 KB Output is correct
65 Correct 5 ms 348 KB Output is correct
66 Correct 6 ms 376 KB Output is correct
67 Correct 13 ms 504 KB Output is correct
68 Correct 8 ms 256 KB Output is correct
69 Correct 7 ms 376 KB Output is correct
70 Correct 10 ms 380 KB Output is correct
71 Partially correct 55 ms 2040 KB Partially correct - number of queries: 6957
72 Correct 15 ms 888 KB Output is correct
73 Partially correct 49 ms 2128 KB Partially correct - number of queries: 6873
74 Partially correct 62 ms 2036 KB Partially correct - number of queries: 6909
75 Correct 7 ms 432 KB Output is correct
76 Partially correct 46 ms 1916 KB Partially correct - number of queries: 6093
77 Partially correct 66 ms 1912 KB Partially correct - number of queries: 6477
78 Correct 9 ms 896 KB Output is correct
79 Correct 38 ms 1576 KB Output is correct
80 Partially correct 61 ms 2016 KB Partially correct - number of queries: 6417
81 Partially correct 63 ms 1924 KB Partially correct - number of queries: 6372
82 Partially correct 48 ms 1952 KB Partially correct - number of queries: 6338
83 Correct 7 ms 512 KB Output is correct
84 Partially correct 45 ms 1784 KB Partially correct - number of queries: 5451
85 Partially correct 40 ms 2048 KB Partially correct - number of queries: 6417
86 Correct 7 ms 384 KB Output is correct
87 Correct 7 ms 324 KB Output is correct
88 Correct 7 ms 384 KB Output is correct
89 Correct 8 ms 412 KB Output is correct
90 Correct 5 ms 464 KB Output is correct
91 Correct 7 ms 512 KB Output is correct
92 Correct 6 ms 376 KB Output is correct
93 Correct 6 ms 676 KB Output is correct
94 Correct 13 ms 760 KB Output is correct
95 Correct 9 ms 760 KB Output is correct
96 Correct 11 ms 640 KB Output is correct
97 Correct 7 ms 384 KB Output is correct