답안 #1075948

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1075948 2024-08-26T09:58:49 Z Abito 커다란 상품 (IOI17_prize) C++17
90 / 100
64 ms 2424 KB
#include "prize.h"
#include <bits/stdc++.h>
//#define int long long
using namespace std;
const int N=2e5+5;
int ans[N][2],S;
bool vis[N];
int32_t find_best(int32_t n) {
	int s=0,mx=0;
	for (int i=0;i<min(500,n);i++){
		vector<int32_t> v=ask(i);
		ans[i][0]=v[0];
		ans[i][1]=v[1];
		vis[i]=1;
		if (v[0]+v[1]==0) return i;
		if (v[0]+v[1]>mx){
			mx=v[0]+v[1];
			s=i;
		}
	}
	while (s<=n){
		int l=s,r=n,mid,idx;
		while (l<=r){
			mid=(l+r)/2;
			if (!vis[mid]){
				vector<int> v=ask(mid);
				ans[mid][0]=v[0];
				ans[mid][1]=v[1];
			}
			if (ans[mid][0]==ans[s][0] && ans[mid][1]==ans[s][1]){
				idx=mid;
				l=mid+1;
			}else r=mid-1;
		}
		if (idx==n) break;
		for (int i=idx+1;i<=n;i++){
			if (!vis[i]){
				vector<int> v=ask(i);
				ans[i][0]=v[0];
				ans[i][1]=v[1];
			}
			if (ans[i][0]+ans[i][1]==mx){
				s=i;
				break;
			}
			if (ans[i][0]+ans[i][1]==0) return i;
		}
	}
	return 0;
}

Compilation message

prize.cpp: In function 'int32_t find_best(int32_t)':
prize.cpp:22:19: warning: 'idx' may be used uninitialized in this function [-Wmaybe-uninitialized]
   22 |   int l=s,r=n,mid,idx;
      |                   ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 3 ms 344 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
5 Correct 2 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 3 ms 344 KB Output is correct
8 Correct 3 ms 344 KB Output is correct
9 Correct 4 ms 348 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 4 ms 344 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 4 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 3 ms 344 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 3 ms 344 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 4 ms 856 KB Output is correct
12 Correct 3 ms 344 KB Output is correct
13 Correct 5 ms 1112 KB Output is correct
14 Correct 4 ms 456 KB Output is correct
15 Correct 8 ms 856 KB Output is correct
16 Partially correct 29 ms 1984 KB Partially correct - number of queries: 7819
17 Correct 2 ms 344 KB Output is correct
18 Partially correct 53 ms 1940 KB Partially correct - number of queries: 9099
19 Correct 3 ms 604 KB Output is correct
20 Correct 12 ms 1112 KB Output is correct
21 Correct 20 ms 1672 KB Output is correct
22 Correct 6 ms 856 KB Output is correct
23 Correct 3 ms 452 KB Output is correct
24 Correct 2 ms 344 KB Output is correct
25 Partially correct 29 ms 1692 KB Partially correct - number of queries: 5345
26 Partially correct 28 ms 1564 KB Partially correct - number of queries: 5277
27 Correct 3 ms 344 KB Output is correct
28 Partially correct 46 ms 1724 KB Partially correct - number of queries: 8666
29 Partially correct 40 ms 1876 KB Partially correct - number of queries: 6681
30 Partially correct 50 ms 1780 KB Partially correct - number of queries: 9024
31 Correct 2 ms 344 KB Output is correct
32 Correct 3 ms 856 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 15 ms 1384 KB Output is correct
35 Correct 4 ms 716 KB Output is correct
36 Correct 17 ms 1360 KB Output is correct
37 Correct 4 ms 856 KB Output is correct
38 Correct 3 ms 452 KB Output is correct
39 Correct 29 ms 1764 KB Output is correct
40 Partially correct 43 ms 1872 KB Partially correct - number of queries: 7781
41 Partially correct 43 ms 1496 KB Partially correct - number of queries: 5635
42 Partially correct 26 ms 2000 KB Partially correct - number of queries: 5635
43 Partially correct 20 ms 1360 KB Partially correct - number of queries: 5136
44 Correct 15 ms 1356 KB Output is correct
45 Correct 18 ms 1336 KB Output is correct
46 Correct 2 ms 344 KB Output is correct
47 Correct 21 ms 1280 KB Output is correct
48 Partially correct 44 ms 1944 KB Partially correct - number of queries: 6847
49 Correct 6 ms 856 KB Output is correct
50 Partially correct 64 ms 1852 KB Partially correct - number of queries: 9094
51 Correct 22 ms 1576 KB Output is correct
52 Correct 3 ms 344 KB Output is correct
53 Correct 4 ms 656 KB Output is correct
54 Correct 21 ms 1360 KB Output is correct
55 Correct 2 ms 344 KB Output is correct
56 Partially correct 50 ms 2424 KB Partially correct - number of queries: 9092
57 Partially correct 38 ms 1620 KB Partially correct - number of queries: 6763
58 Partially correct 39 ms 1672 KB Partially correct - number of queries: 6868
59 Partially correct 30 ms 1708 KB Partially correct - number of queries: 5635
60 Partially correct 24 ms 1616 KB Partially correct - number of queries: 5263
61 Correct 3 ms 600 KB Output is correct
62 Correct 4 ms 344 KB Output is correct
63 Correct 4 ms 600 KB Output is correct
64 Correct 3 ms 344 KB Output is correct
65 Correct 3 ms 344 KB Output is correct
66 Correct 3 ms 344 KB Output is correct
67 Correct 3 ms 344 KB Output is correct
68 Correct 4 ms 452 KB Output is correct
69 Correct 6 ms 436 KB Output is correct
70 Correct 4 ms 452 KB Output is correct
71 Partially correct 39 ms 2124 KB Partially correct - number of queries: 9237
72 Correct 6 ms 1112 KB Output is correct
73 Partially correct 46 ms 1980 KB Partially correct - number of queries: 9116
74 Partially correct 51 ms 2184 KB Partially correct - number of queries: 9178
75 Correct 2 ms 600 KB Output is correct
76 Partially correct 48 ms 2392 KB Partially correct - number of queries: 7945
77 Partially correct 48 ms 1824 KB Partially correct - number of queries: 9117
78 Correct 5 ms 1112 KB Output is correct
79 Correct 15 ms 1872 KB Output is correct
80 Partially correct 45 ms 2044 KB Partially correct - number of queries: 9131
81 Partially correct 54 ms 1768 KB Partially correct - number of queries: 9119
82 Partially correct 46 ms 1980 KB Partially correct - number of queries: 9034
83 Correct 3 ms 600 KB Output is correct
84 Partially correct 44 ms 1856 KB Partially correct - number of queries: 7512
85 Partially correct 50 ms 1872 KB Partially correct - number of queries: 9109
86 Correct 3 ms 456 KB Output is correct
87 Correct 2 ms 344 KB Output is correct
88 Correct 3 ms 344 KB Output is correct
89 Correct 3 ms 344 KB Output is correct
90 Correct 2 ms 344 KB Output is correct
91 Correct 3 ms 344 KB Output is correct
92 Correct 3 ms 344 KB Output is correct
93 Correct 4 ms 856 KB Output is correct
94 Correct 8 ms 1112 KB Output is correct
95 Correct 4 ms 856 KB Output is correct
96 Correct 5 ms 856 KB Output is correct
97 Correct 3 ms 344 KB Output is correct