답안 #817768

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
817768 2023-08-09T15:56:32 Z FEDIKUS 커다란 상품 (IOI17_prize) C++17
97.61 / 100
48 ms 432 KB
#include "prize.h"
#include<bits/stdc++.h>

using namespace std;

const int maxn=2e5+10;
const int koren=480;

int res=-1;
int maxi=0;
int n;
int q=0;
map<int,int> najr;
map<int,int> najl;

int find_best(int _n) {
	n=_n;
	map<int,int> kurac;
	vector<int> sta(koren);
	for(int i=0;i<koren;i++){
		auto rez=ask(i);
		q++;
		maxi=max(maxi,rez[0]+rez[1]);
		kurac[rez[0]+rez[1]]++;
		sta[i]=rez[0]+rez[1];
		if(rez[0]+rez[1]==0) return i;
	}
	int klk=koren-kurac[maxi];
	int tren=koren-1;
	while(true){
		int l=tren+1;
		int r=n-1;
		int sled=-1;
		if(najr.find(klk)!=najr.end()) l=najr[klk]+1;
		auto it=najl.upper_bound(klk);
		if(it!=najl.end()) r=it->second-1;
		while(l<=r){
			int mid=l+(r-l)/2;
			auto rez=ask(mid);
			q++;
			if(q==10000) exit(-1);
			if(rez[0]+rez[1]==0) return mid;
			if(rez[0]+rez[1]<maxi){
				sled=mid;
				r=mid-1;
			}else{
				najr[rez[0]]=max(najr[rez[0]],mid);
				if(najl.find(rez[0])==najl.end()) najl[rez[0]]=n;
				najl[rez[0]]=min(najl[rez[0]],mid);
				if(rez[0]==klk){
					l=mid+1;
				}else{
					r=mid-1;
				}
			}
		}
		tren=sled;
		klk++;
	}
	return res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 208 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 4 ms 288 KB Output is correct
4 Correct 2 ms 304 KB Output is correct
5 Correct 2 ms 344 KB Output is correct
6 Correct 1 ms 288 KB Output is correct
7 Correct 3 ms 288 KB Output is correct
8 Correct 3 ms 208 KB Output is correct
9 Correct 4 ms 208 KB Output is correct
10 Correct 4 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 300 KB Output is correct
2 Correct 6 ms 300 KB Output is correct
3 Correct 3 ms 292 KB Output is correct
4 Correct 2 ms 296 KB Output is correct
5 Correct 4 ms 292 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 4 ms 208 KB Output is correct
8 Correct 4 ms 288 KB Output is correct
9 Correct 2 ms 356 KB Output is correct
10 Correct 5 ms 296 KB Output is correct
11 Correct 6 ms 208 KB Output is correct
12 Correct 5 ms 296 KB Output is correct
13 Correct 5 ms 296 KB Output is correct
14 Correct 6 ms 208 KB Output is correct
15 Correct 8 ms 280 KB Output is correct
16 Correct 16 ms 324 KB Output is correct
17 Correct 2 ms 208 KB Output is correct
18 Partially correct 48 ms 284 KB Partially correct - number of queries: 5076
19 Correct 2 ms 292 KB Output is correct
20 Correct 14 ms 300 KB Output is correct
21 Correct 12 ms 432 KB Output is correct
22 Correct 3 ms 344 KB Output is correct
23 Correct 4 ms 292 KB Output is correct
24 Correct 3 ms 208 KB Output is correct
25 Correct 17 ms 292 KB Output is correct
26 Correct 10 ms 336 KB Output is correct
27 Correct 4 ms 420 KB Output is correct
28 Correct 22 ms 288 KB Output is correct
29 Correct 19 ms 304 KB Output is correct
30 Partially correct 37 ms 312 KB Partially correct - number of queries: 5054
31 Correct 5 ms 208 KB Output is correct
32 Correct 4 ms 416 KB Output is correct
33 Correct 0 ms 208 KB Output is correct
34 Correct 11 ms 296 KB Output is correct
35 Correct 3 ms 308 KB Output is correct
36 Correct 12 ms 304 KB Output is correct
37 Correct 5 ms 296 KB Output is correct
38 Correct 4 ms 288 KB Output is correct
39 Correct 22 ms 292 KB Output is correct
40 Correct 45 ms 316 KB Output is correct
41 Correct 20 ms 292 KB Output is correct
42 Correct 12 ms 320 KB Output is correct
43 Correct 24 ms 296 KB Output is correct
44 Correct 21 ms 284 KB Output is correct
45 Correct 17 ms 292 KB Output is correct
46 Correct 4 ms 208 KB Output is correct
47 Correct 15 ms 296 KB Output is correct
48 Correct 13 ms 312 KB Output is correct
49 Correct 5 ms 208 KB Output is correct
50 Partially correct 35 ms 296 KB Partially correct - number of queries: 5097
51 Correct 16 ms 300 KB Output is correct
52 Correct 2 ms 300 KB Output is correct
53 Correct 3 ms 296 KB Output is correct
54 Correct 9 ms 308 KB Output is correct
55 Correct 2 ms 288 KB Output is correct
56 Partially correct 45 ms 304 KB Partially correct - number of queries: 5068
57 Correct 30 ms 308 KB Output is correct
58 Correct 13 ms 316 KB Output is correct
59 Correct 12 ms 320 KB Output is correct
60 Correct 19 ms 288 KB Output is correct
61 Correct 4 ms 328 KB Output is correct
62 Correct 3 ms 296 KB Output is correct
63 Correct 6 ms 292 KB Output is correct
64 Correct 5 ms 292 KB Output is correct
65 Correct 4 ms 292 KB Output is correct
66 Correct 31 ms 288 KB Output is correct
67 Correct 3 ms 208 KB Output is correct
68 Correct 2 ms 296 KB Output is correct
69 Correct 18 ms 300 KB Output is correct
70 Correct 2 ms 304 KB Output is correct
71 Partially correct 30 ms 324 KB Partially correct - number of queries: 5239
72 Correct 6 ms 336 KB Output is correct
73 Partially correct 32 ms 316 KB Partially correct - number of queries: 5176
74 Partially correct 36 ms 316 KB Partially correct - number of queries: 5203
75 Correct 6 ms 304 KB Output is correct
76 Correct 38 ms 308 KB Output is correct
77 Partially correct 24 ms 208 KB Partially correct - number of queries: 5238
78 Correct 4 ms 344 KB Output is correct
79 Correct 10 ms 300 KB Output is correct
80 Partially correct 31 ms 308 KB Partially correct - number of queries: 5239
81 Partially correct 36 ms 208 KB Partially correct - number of queries: 5234
82 Partially correct 46 ms 300 KB Partially correct - number of queries: 5185
83 Correct 5 ms 208 KB Output is correct
84 Correct 36 ms 300 KB Output is correct
85 Partially correct 40 ms 300 KB Partially correct - number of queries: 5212
86 Correct 4 ms 292 KB Output is correct
87 Correct 5 ms 208 KB Output is correct
88 Correct 4 ms 208 KB Output is correct
89 Correct 5 ms 208 KB Output is correct
90 Correct 5 ms 208 KB Output is correct
91 Correct 4 ms 300 KB Output is correct
92 Correct 4 ms 208 KB Output is correct
93 Correct 5 ms 208 KB Output is correct
94 Correct 5 ms 208 KB Output is correct
95 Correct 4 ms 300 KB Output is correct
96 Correct 5 ms 208 KB Output is correct
97 Correct 4 ms 208 KB Output is correct