Submission #104337

# Submission time Handle Problem Language Result Execution time Memory
104337 2019-04-05T10:48:16 Z turbat The Big Prize (IOI17_prize) C++14
20 / 100
102 ms 2156 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];
void add(int x){
	x++;
	while (x < N){
		fen[x]++;
		x += x & -x;
	}
}
int sum(int x){
	x++;
	int s = 0;
	while (x){
		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;
	if (l == r) {
		tmp = askk(l);
		if (tmp[0] + tmp[1] == 0) return l;	
		return -1;
	}
	while(l <= r){
		tmp = askk(r);
		if (tmp[0] + tmp[1] == 0) return r;
		if (tmp[0] + tmp[1] == mx) break;
		add(r);
		r--;
	}
	vi tmp1;
	while (l <= r){
		tmp1 = askk(l);
		if (tmp1[0] + tmp1[1] == 0) return l;
		if (tmp1[0] + tmp1[1] == mx) break;
		add(l);
		l++;
	}
	if (l > r) return -1;
	if (tmp[0] == tmp1[0]) return -1;
	if (l == r) return gg(l, r);
	int mid = (l + r) / 2;
	int ind = gg(l , mid);
	if (ind != -1) return ind;
	else return gg(mid + 1, r - 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 * i < n;i++)
		if (s[i] != mx)
			add(i);
	// vi ans = askk(0);
	// mx = ans[0] + ans[1];
	return gg(500, n - 1);
}
# Verdict Execution time Memory Grader output
1 Correct 11 ms 308 KB Output is correct
2 Correct 7 ms 308 KB Output is correct
3 Correct 8 ms 324 KB Output is correct
4 Correct 8 ms 384 KB Output is correct
5 Correct 6 ms 448 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 6 ms 412 KB Output is correct
8 Correct 11 ms 376 KB Output is correct
9 Correct 8 ms 376 KB Output is correct
10 Correct 7 ms 464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 576 KB Output is correct
2 Correct 9 ms 384 KB Output is correct
3 Correct 8 ms 376 KB Output is correct
4 Correct 8 ms 256 KB Output is correct
5 Correct 4 ms 444 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 10 ms 256 KB Output is correct
9 Correct 5 ms 372 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 11 ms 504 KB Output is correct
12 Correct 6 ms 376 KB Output is correct
13 Correct 10 ms 832 KB Output is correct
14 Correct 8 ms 384 KB Output is correct
15 Correct 16 ms 684 KB Output is correct
16 Partially correct 102 ms 1848 KB Partially correct - number of queries: 8929
17 Correct 7 ms 256 KB Output is correct
18 Incorrect 91 ms 2156 KB Incorrect
19 Halted 0 ms 0 KB -