답안 #1029230

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1029230 2024-07-20T14:06:09 Z amirhoseinfar1385 커다란 상품 (IOI17_prize) C++17
90 / 100
193 ms 1492 KB
#include "prize.h"
#include<bits/stdc++.h>
using namespace std;
map<int,pair<int,int>>mp;
int cnta=0;

pair<int,int>pors(int u){
	if(mp.count(u)==0){
		cnta++;
		if(cnta>=10000){
			exit(23);
		}
		vector<int>hey=ask(u);
		mp[u]=make_pair(hey[0],hey[1]);
	}
	return mp[u];
}
 
int find_best(int n) {
	mp.clear();
	int cnta=0;
	int wtf=-1;
	for(int i=0;i<n;){
		//cout<<i<<endl;
		pair<int,int>av=pors(i);
		if(av.first+av.second==0){
			return i;
		}
		cnta++;
		pair<int,int>fake;
		if(wtf!=-1){
			fake=pors(wtf);
			if(av.first+av.second<=fake.first+fake.second){
				i++;
				continue;
			}
		}
		int low=i,high=n,mid,f=0;
		for(auto x:mp){
			mid=x.first;
			fake=pors(mid);
			if(fake.first+fake.second!=av.first+av.second){
				if(fake.first+fake.second>av.first+av.second){
					f=1;
					break;
				}
				high=mid;
			}else{
				if(fake.first-av.first==0){
					low=mid;
					high=n;
				}else{
					high=mid;
				}
			}
		}
		if(f){
			wtf=i;
			i=low+1;
			continue;
		}
		low=max(low,i);
		while(high-low>1){
			mid=(high+low)>>1;
			fake=pors(mid);
			if(fake.first+fake.second!=av.first+av.second){
				if(fake.first+fake.second>av.first+av.second){
					wtf=i;
					break;
				}
				high=mid;
			}else{
				if(fake.first-av.first==0){
					low=mid;
				}else{
					high=mid;
				}
			}
		}
		i=low+1;
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 596 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 428 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 2 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 3 ms 344 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Correct 7 ms 476 KB Output is correct
16 Partially correct 139 ms 600 KB Partially correct - number of queries: 5648
17 Correct 0 ms 344 KB Output is correct
18 Partially correct 193 ms 964 KB Partially correct - number of queries: 6587
19 Correct 1 ms 344 KB Output is correct
20 Correct 15 ms 600 KB Output is correct
21 Correct 34 ms 736 KB Output is correct
22 Correct 3 ms 344 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 67 ms 856 KB Output is correct
26 Correct 60 ms 560 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Partially correct 172 ms 828 KB Partially correct - number of queries: 6476
29 Correct 107 ms 592 KB Output is correct
30 Partially correct 193 ms 848 KB Partially correct - number of queries: 6579
31 Correct 0 ms 344 KB Output is correct
32 Correct 2 ms 344 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 24 ms 344 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 11 ms 344 KB Output is correct
37 Correct 1 ms 344 KB Output is correct
38 Correct 0 ms 432 KB Output is correct
39 Correct 40 ms 616 KB Output is correct
40 Partially correct 130 ms 812 KB Partially correct - number of queries: 5613
41 Correct 64 ms 572 KB Output is correct
42 Correct 67 ms 888 KB Output is correct
43 Correct 58 ms 892 KB Output is correct
44 Correct 34 ms 344 KB Output is correct
45 Correct 27 ms 496 KB Output is correct
46 Correct 1 ms 344 KB Output is correct
47 Correct 55 ms 804 KB Output is correct
48 Correct 94 ms 1104 KB Output is correct
49 Correct 4 ms 340 KB Output is correct
50 Partially correct 192 ms 788 KB Partially correct - number of queries: 6615
51 Correct 43 ms 768 KB Output is correct
52 Correct 1 ms 344 KB Output is correct
53 Correct 1 ms 344 KB Output is correct
54 Correct 42 ms 600 KB Output is correct
55 Correct 0 ms 344 KB Output is correct
56 Partially correct 190 ms 1288 KB Partially correct - number of queries: 6626
57 Correct 100 ms 520 KB Output is correct
58 Correct 98 ms 788 KB Output is correct
59 Correct 71 ms 600 KB Output is correct
60 Correct 57 ms 772 KB Output is correct
61 Correct 1 ms 344 KB Output is correct
62 Correct 0 ms 344 KB Output is correct
63 Correct 1 ms 344 KB Output is correct
64 Correct 1 ms 344 KB Output is correct
65 Correct 1 ms 344 KB Output is correct
66 Correct 3 ms 712 KB Output is correct
67 Correct 0 ms 344 KB Output is correct
68 Correct 2 ms 428 KB Output is correct
69 Correct 3 ms 344 KB Output is correct
70 Correct 1 ms 344 KB Output is correct
71 Partially correct 175 ms 824 KB Partially correct - number of queries: 6452
72 Correct 3 ms 344 KB Output is correct
73 Partially correct 168 ms 976 KB Partially correct - number of queries: 6338
74 Partially correct 172 ms 848 KB Partially correct - number of queries: 6392
75 Correct 1 ms 344 KB Output is correct
76 Partially correct 140 ms 728 KB Partially correct - number of queries: 5596
77 Partially correct 187 ms 1492 KB Partially correct - number of queries: 6599
78 Correct 3 ms 344 KB Output is correct
79 Correct 42 ms 796 KB Output is correct
80 Partially correct 174 ms 708 KB Partially correct - number of queries: 6606
81 Partially correct 168 ms 648 KB Partially correct - number of queries: 6603
82 Partially correct 156 ms 780 KB Partially correct - number of queries: 6606
83 Correct 1 ms 344 KB Output is correct
84 Partially correct 123 ms 756 KB Partially correct - number of queries: 5476
85 Partially correct 165 ms 848 KB Partially correct - number of queries: 6606
86 Correct 38 ms 488 KB Output is correct
87 Correct 2 ms 344 KB Output is correct
88 Correct 41 ms 600 KB Output is correct
89 Correct 30 ms 592 KB Output is correct
90 Correct 1 ms 344 KB Output is correct
91 Correct 17 ms 496 KB Output is correct
92 Correct 1 ms 344 KB Output is correct
93 Correct 3 ms 444 KB Output is correct
94 Correct 2 ms 344 KB Output is correct
95 Correct 3 ms 456 KB Output is correct
96 Correct 2 ms 344 KB Output is correct
97 Correct 0 ms 344 KB Output is correct