답안 #291895

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
291895 2020-09-06T00:44:22 Z amiratou 커다란 상품 (IOI17_prize) C++14
97.65 / 100
72 ms 5420 KB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
 
vector<int> h[200005];
int f=-1,N;
vector<int> query(int idx){
	if(!h[idx].empty())return h[idx];
	return h[idx]=ask(idx);
}
int close_left(int l,int r){
	while(l<=r){
		vector<int> M=query(l);
		if((M[0]+M[1])==N)return l;
		else if(!(M[0]+M[1])){f=l;return -1;}
		l++;
	}
	return -1;
}
int close_right(int l,int r){
	while(r>=l){
		vector<int> M=query(r);
		if((M[0]+M[1])==N)return r;
		else if(!(M[0]+M[1])){f=r;return -1;}
		r--;
	}
	return -1;
}
void gimme(int l,int r){
	if(f!=-1)return;
	if(l==r)return ;
	vector<int> G=query(l),G2=query(r);
	if(G2[0]==G[0])return;
	int med=(l+r)>>1,k;
	vector<int> M=query(med);
	if(!(M[0]+M[1])){f=med;return;}
	else if((M[0]+M[1])==N){
		gimme(l,med);
		if(f!=-1)return;
		k=med;
		if(f!=-1)return;
		if(k!=-1)gimme(k,r);
	}
	else{
		k=close_right(l,med-1);
		if(f!=-1)return;
		if(k!=-1)gimme(l,k);
		if(f!=-1)return;
		k=close_left(med+1,r);
		if(f!=-1)return;
		if(k!=-1)gimme(k,r);
	}
}
 
int find_best(int n) {
	N=0;
	for (int i = 0; i < min(474,n); ++i)
	{
		vector<int> Y=query(i);
		if(!(Y[0]+Y[1]))return i;
		else N=max(N,Y[0]+Y[1]);
	}
	int l=close_left(474,n-1);
	if(f!=-1)return f;
	assert(l!=-1);
	int r=close_right(l,n-1);
	if(f!=-1)return f;
	assert(r!=-1);
	gimme(l,r);
	assert(f!=-1);
	return f;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 4992 KB Output is correct
2 Correct 9 ms 4992 KB Output is correct
3 Correct 9 ms 4992 KB Output is correct
4 Correct 8 ms 4992 KB Output is correct
5 Correct 10 ms 4992 KB Output is correct
6 Correct 4 ms 4992 KB Output is correct
7 Correct 8 ms 5112 KB Output is correct
8 Correct 8 ms 4992 KB Output is correct
9 Correct 9 ms 4992 KB Output is correct
10 Correct 11 ms 4992 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 4992 KB Output is correct
2 Correct 8 ms 5024 KB Output is correct
3 Correct 8 ms 4992 KB Output is correct
4 Correct 8 ms 4992 KB Output is correct
5 Correct 8 ms 4992 KB Output is correct
6 Correct 4 ms 4992 KB Output is correct
7 Correct 8 ms 5056 KB Output is correct
8 Correct 8 ms 4992 KB Output is correct
9 Correct 9 ms 4992 KB Output is correct
10 Correct 8 ms 4992 KB Output is correct
11 Correct 10 ms 4992 KB Output is correct
12 Correct 7 ms 4992 KB Output is correct
13 Correct 12 ms 4992 KB Output is correct
14 Correct 10 ms 4992 KB Output is correct
15 Correct 15 ms 4992 KB Output is correct
16 Correct 54 ms 5240 KB Output is correct
17 Correct 9 ms 4992 KB Output is correct
18 Partially correct 65 ms 5112 KB Partially correct - number of queries: 5064
19 Correct 9 ms 5112 KB Output is correct
20 Correct 13 ms 5116 KB Output is correct
21 Correct 32 ms 5112 KB Output is correct
22 Correct 12 ms 4992 KB Output is correct
23 Correct 10 ms 4992 KB Output is correct
24 Correct 10 ms 4992 KB Output is correct
25 Correct 36 ms 5112 KB Output is correct
26 Correct 36 ms 5112 KB Output is correct
27 Correct 10 ms 4992 KB Output is correct
28 Correct 56 ms 5112 KB Output is correct
29 Correct 46 ms 5112 KB Output is correct
30 Partially correct 58 ms 5112 KB Partially correct - number of queries: 5006
31 Correct 8 ms 4992 KB Output is correct
32 Correct 13 ms 4992 KB Output is correct
33 Correct 3 ms 4992 KB Output is correct
34 Correct 23 ms 5112 KB Output is correct
35 Correct 7 ms 5096 KB Output is correct
36 Correct 12 ms 5156 KB Output is correct
37 Correct 8 ms 4992 KB Output is correct
38 Correct 8 ms 5072 KB Output is correct
39 Correct 25 ms 5112 KB Output is correct
40 Correct 42 ms 5112 KB Output is correct
41 Correct 38 ms 5088 KB Output is correct
42 Correct 39 ms 5112 KB Output is correct
43 Correct 38 ms 5112 KB Output is correct
44 Correct 25 ms 5112 KB Output is correct
45 Correct 13 ms 5168 KB Output is correct
46 Correct 10 ms 4992 KB Output is correct
47 Correct 24 ms 5156 KB Output is correct
48 Correct 40 ms 5112 KB Output is correct
49 Correct 13 ms 4992 KB Output is correct
50 Partially correct 67 ms 5112 KB Partially correct - number of queries: 5082
51 Correct 35 ms 5112 KB Output is correct
52 Correct 10 ms 4992 KB Output is correct
53 Correct 9 ms 4992 KB Output is correct
54 Correct 37 ms 5112 KB Output is correct
55 Correct 10 ms 5024 KB Output is correct
56 Partially correct 52 ms 5420 KB Partially correct - number of queries: 5079
57 Correct 52 ms 5112 KB Output is correct
58 Correct 52 ms 5112 KB Output is correct
59 Correct 42 ms 5112 KB Output is correct
60 Correct 40 ms 5112 KB Output is correct
61 Correct 11 ms 4992 KB Output is correct
62 Correct 9 ms 5120 KB Output is correct
63 Correct 7 ms 5136 KB Output is correct
64 Correct 11 ms 4992 KB Output is correct
65 Correct 8 ms 4992 KB Output is correct
66 Correct 6 ms 5128 KB Output is correct
67 Correct 14 ms 4992 KB Output is correct
68 Correct 8 ms 4992 KB Output is correct
69 Correct 10 ms 4992 KB Output is correct
70 Correct 13 ms 4992 KB Output is correct
71 Partially correct 45 ms 5112 KB Partially correct - number of queries: 5235
72 Correct 12 ms 4992 KB Output is correct
73 Partially correct 72 ms 5112 KB Partially correct - number of queries: 5172
74 Partially correct 58 ms 5240 KB Partially correct - number of queries: 5199
75 Correct 11 ms 4992 KB Output is correct
76 Correct 50 ms 5204 KB Output is correct
77 Partially correct 65 ms 5216 KB Partially correct - number of queries: 5172
78 Correct 15 ms 4992 KB Output is correct
79 Correct 29 ms 5112 KB Output is correct
80 Partially correct 65 ms 5112 KB Partially correct - number of queries: 5209
81 Partially correct 68 ms 5112 KB Partially correct - number of queries: 5189
82 Partially correct 46 ms 5112 KB Partially correct - number of queries: 5178
83 Correct 11 ms 4992 KB Output is correct
84 Correct 61 ms 5112 KB Output is correct
85 Partially correct 51 ms 5112 KB Partially correct - number of queries: 5180
86 Correct 9 ms 4992 KB Output is correct
87 Correct 8 ms 4992 KB Output is correct
88 Correct 8 ms 4992 KB Output is correct
89 Correct 8 ms 4992 KB Output is correct
90 Correct 9 ms 4992 KB Output is correct
91 Correct 9 ms 4992 KB Output is correct
92 Correct 9 ms 4992 KB Output is correct
93 Correct 12 ms 4992 KB Output is correct
94 Correct 8 ms 5156 KB Output is correct
95 Correct 14 ms 4992 KB Output is correct
96 Correct 8 ms 5220 KB Output is correct
97 Correct 11 ms 4992 KB Output is correct