답안 #713049

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
713049 2023-03-21T01:14:14 Z dungnguyenn_05 커다란 상품 (IOI17_prize) C++17
90 / 100
120 ms 344 KB
#include "prize.h"
#include<bits/stdc++.h>
#define fs first
#define sc second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pi;

vector<pi> srt;
int mx;

int find_best(int n) 
{
	for(int i=0;i<min(n,500);i++)
	{
		vi ans=ask(i);
		srt.pb({ans[0]+ans[1],i});
	}

	sort(all(srt));
	mx=srt.back().fs;

	srt.clear();

	int st=0;
	while(st<n)
	{
		vi ans=ask(st);

		if(ans[0]+ans[1]!=mx)
		{
			srt.pb({ans[0]+ans[1],st});
			st++;
		}
		else
		{
			int l=st,r=n-1,pos;
			while(l<=r)
			{
				int mid=(l+r)>>1;

				vi new_ans=ask(mid);
				if(new_ans[0]+new_ans[1]!=mx or (new_ans[0]+new_ans[1]==mx and new_ans[1]<ans[1]))
					r=mid-1;
				else
				{
					l=mid+1;
					pos=mid;
				}
			}

			st=pos+1;
		}
	}

	sort(all(srt));

	return srt[0].sc;
}















Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:54:10: warning: 'pos' may be used uninitialized in this function [-Wmaybe-uninitialized]
   54 |    st=pos+1;
      |       ~~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 208 KB Output is correct
2 Correct 5 ms 208 KB Output is correct
3 Correct 7 ms 344 KB Output is correct
4 Correct 9 ms 316 KB Output is correct
5 Correct 8 ms 288 KB Output is correct
6 Correct 6 ms 288 KB Output is correct
7 Correct 5 ms 288 KB Output is correct
8 Correct 5 ms 296 KB Output is correct
9 Correct 6 ms 292 KB Output is correct
10 Correct 6 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 208 KB Output is correct
2 Correct 6 ms 288 KB Output is correct
3 Correct 4 ms 208 KB Output is correct
4 Correct 4 ms 284 KB Output is correct
5 Correct 3 ms 280 KB Output is correct
6 Correct 5 ms 292 KB Output is correct
7 Correct 7 ms 288 KB Output is correct
8 Correct 6 ms 280 KB Output is correct
9 Correct 5 ms 208 KB Output is correct
10 Correct 4 ms 208 KB Output is correct
11 Correct 13 ms 288 KB Output is correct
12 Correct 13 ms 280 KB Output is correct
13 Correct 14 ms 340 KB Output is correct
14 Correct 21 ms 304 KB Output is correct
15 Partially correct 88 ms 284 KB Partially correct - number of queries: 8668
16 Partially correct 106 ms 280 KB Partially correct - number of queries: 9118
17 Partially correct 92 ms 272 KB Partially correct - number of queries: 9131
18 Partially correct 74 ms 284 KB Partially correct - number of queries: 9123
19 Partially correct 72 ms 284 KB Partially correct - number of queries: 8569
20 Partially correct 62 ms 296 KB Partially correct - number of queries: 6099
21 Partially correct 89 ms 292 KB Partially correct - number of queries: 9047
22 Partially correct 76 ms 280 KB Partially correct - number of queries: 6858
23 Correct 9 ms 288 KB Output is correct
24 Correct 5 ms 280 KB Output is correct
25 Partially correct 76 ms 288 KB Partially correct - number of queries: 9114
26 Partially correct 101 ms 208 KB Partially correct - number of queries: 9030
27 Correct 8 ms 288 KB Output is correct
28 Partially correct 67 ms 292 KB Partially correct - number of queries: 8992
29 Partially correct 57 ms 284 KB Partially correct - number of queries: 7423
30 Partially correct 65 ms 284 KB Partially correct - number of queries: 9046
31 Partially correct 75 ms 284 KB Partially correct - number of queries: 9037
32 Correct 14 ms 284 KB Output is correct
33 Correct 2 ms 208 KB Output is correct
34 Partially correct 36 ms 284 KB Partially correct - number of queries: 9123
35 Correct 12 ms 280 KB Output is correct
36 Partially correct 105 ms 276 KB Partially correct - number of queries: 9070
37 Correct 10 ms 288 KB Output is correct
38 Correct 3 ms 276 KB Output is correct
39 Partially correct 103 ms 280 KB Partially correct - number of queries: 9041
40 Partially correct 68 ms 280 KB Partially correct - number of queries: 7801
41 Partially correct 88 ms 272 KB Partially correct - number of queries: 9114
42 Partially correct 41 ms 276 KB Partially correct - number of queries: 9114
43 Partially correct 90 ms 272 KB Partially correct - number of queries: 8848
44 Partially correct 39 ms 284 KB Partially correct - number of queries: 9127
45 Partially correct 93 ms 280 KB Partially correct - number of queries: 9142
46 Partially correct 104 ms 284 KB Partially correct - number of queries: 9136
47 Partially correct 79 ms 288 KB Partially correct - number of queries: 9156
48 Partially correct 120 ms 280 KB Partially correct - number of queries: 9122
49 Partially correct 84 ms 284 KB Partially correct - number of queries: 9121
50 Partially correct 108 ms 292 KB Partially correct - number of queries: 9117
51 Partially correct 73 ms 284 KB Partially correct - number of queries: 9140
52 Partially correct 81 ms 208 KB Partially correct - number of queries: 9118
53 Correct 4 ms 284 KB Output is correct
54 Partially correct 61 ms 280 KB Partially correct - number of queries: 9057
55 Partially correct 43 ms 292 KB Partially correct - number of queries: 9121
56 Partially correct 67 ms 288 KB Partially correct - number of queries: 9116
57 Partially correct 75 ms 208 KB Partially correct - number of queries: 9047
58 Partially correct 106 ms 276 KB Partially correct - number of queries: 9120
59 Partially correct 97 ms 292 KB Partially correct - number of queries: 9115
60 Partially correct 76 ms 292 KB Partially correct - number of queries: 9040
61 Correct 7 ms 288 KB Output is correct
62 Correct 5 ms 208 KB Output is correct
63 Correct 8 ms 280 KB Output is correct
64 Correct 9 ms 284 KB Output is correct
65 Correct 4 ms 284 KB Output is correct
66 Correct 9 ms 268 KB Output is correct
67 Correct 13 ms 208 KB Output is correct
68 Correct 15 ms 280 KB Output is correct
69 Correct 11 ms 208 KB Output is correct
70 Correct 8 ms 208 KB Output is correct
71 Partially correct 79 ms 292 KB Partially correct - number of queries: 9245
72 Correct 9 ms 208 KB Output is correct
73 Partially correct 79 ms 304 KB Partially correct - number of queries: 9114
74 Partially correct 85 ms 208 KB Partially correct - number of queries: 9192
75 Correct 6 ms 304 KB Output is correct
76 Partially correct 77 ms 296 KB Partially correct - number of queries: 7941
77 Partially correct 59 ms 292 KB Partially correct - number of queries: 9118
78 Correct 13 ms 304 KB Output is correct
79 Correct 45 ms 208 KB Output is correct
80 Partially correct 99 ms 292 KB Partially correct - number of queries: 9124
81 Partially correct 95 ms 208 KB Partially correct - number of queries: 9092
82 Partially correct 70 ms 208 KB Partially correct - number of queries: 9060
83 Correct 6 ms 208 KB Output is correct
84 Partially correct 67 ms 208 KB Partially correct - number of queries: 7553
85 Partially correct 64 ms 208 KB Partially correct - number of queries: 9150
86 Correct 7 ms 292 KB Output is correct
87 Correct 4 ms 304 KB Output is correct
88 Correct 11 ms 304 KB Output is correct
89 Correct 8 ms 296 KB Output is correct
90 Correct 6 ms 308 KB Output is correct
91 Correct 6 ms 292 KB Output is correct
92 Correct 10 ms 288 KB Output is correct
93 Correct 15 ms 208 KB Output is correct
94 Correct 16 ms 208 KB Output is correct
95 Correct 10 ms 300 KB Output is correct
96 Correct 11 ms 208 KB Output is correct
97 Correct 8 ms 208 KB Output is correct