답안 #314095

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
314095 2020-10-18T09:56:03 Z keta_tsimakuridze 커다란 상품 (IOI17_prize) C++14
96.17 / 100
63 ms 2808 KB
#include "prize.h"
#define f first
#define s second
#include<bits/stdc++.h>
int l,r,mid,mx,ind,le,idx,R;
std::pair<int,std::pair<int,int> > b[200005],P[200005];
int find_best(int n) {
	int f=474;
	if(f>n) f=n;
	for(int i = 0; i <f; i++) {
		std::vector<int> res = ask(i);
		if(res[0] + res[1] == 0)
			return i;
			P[i]={1,{res[0],res[1]}};
		if(mx<=res[0]+res[1]) mx=res[0]+res[1],ind=i,le=res[0];
	}
	f=sqrt(n);
	for(int i=f;i<n;i+=f){
		std::vector<int> res;
		res.resize(2);
			if(!P[i].f)res= ask(i),P[i]={1,{res[0],res[1]}};
			else res[0]=P[i].s.f,res[1]=P[i].s.s;
		R++;
		b[R]={res[0]+res[1],{res[0],i}};
		P[i]={1,{res[0],res[1]}};
		if(res[0]+res[1]==0) return i;
	}
	if(R*f!=n-1){ 
	R++;
	std::vector<int> res;
	res.resize(2);
			if(!P[n-1].f)res= ask(n-1),P[n-1]={1,{res[0],res[1]}};
			else res[0]=P[n-1].s.f,res[1]=P[n-1].s.s;
	b[R]={res[0]+res[1],{res[0],n-1}};
	if(res[0]+res[1]==0) return (n-1);
	}
	while(true){
		int l=ind/f+1;
		int r=R;
		while(l<=r){
			int mid=(l+r)/2;
			if(b[mid].f==mx && b[mid].s.f==le){
				l=mid+1;
			}
			else {
				idx=mid;
				r=mid-1;
			}
		}
		 l=b[idx-1].s.s;
		 if(ind+1>l) l=ind+1;
		 r=b[idx].s.s;
		while(l<=r){
			int mid=(l+r)/2;
			std::vector<int> res;
			res.resize(2);
			if(!P[mid].f)res= ask(mid),P[mid]={1,{res[0],res[1]}};
			else res[0]=P[mid].s.f,res[1]=P[mid].s.s;
			
			if(res[0]+res[1]==0) return mid;
			if(res[0]+res[1]==mx && le==res[0]) {
			l=mid+1;
			}else{
				if(res[0]+res[1]!=mx)idx=mid;
				r=mid-1;
			}
		}
		while(true){
			idx++;
			std::vector<int> res;
			res.resize(2);
			if(!P[idx].f) res= ask(idx);
			else res[0]=P[idx].s.f,res[1]=P[idx].s.s;
			if(res[0]+res[1]==mx){
			 ind=idx;le=res[0];break;}
			if(res[0]+res[1]==0) return idx;
		}
	}
	return 0;
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:12:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   12 |   if(res[0] + res[1] == 0)
      |   ^~
prize.cpp:14:4: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   14 |    P[i]={1,{res[0],res[1]}};
      |    ^
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 2168 KB Output is correct
2 Correct 11 ms 2168 KB Output is correct
3 Correct 9 ms 2168 KB Output is correct
4 Correct 11 ms 2176 KB Output is correct
5 Correct 11 ms 2172 KB Output is correct
6 Correct 1 ms 376 KB Output is correct
7 Correct 11 ms 2176 KB Output is correct
8 Correct 11 ms 2168 KB Output is correct
9 Correct 13 ms 2168 KB Output is correct
10 Correct 11 ms 2168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 2168 KB Output is correct
2 Correct 12 ms 2168 KB Output is correct
3 Correct 10 ms 2168 KB Output is correct
4 Correct 11 ms 2176 KB Output is correct
5 Correct 12 ms 2156 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 12 ms 2296 KB Output is correct
8 Correct 12 ms 2168 KB Output is correct
9 Correct 10 ms 2304 KB Output is correct
10 Correct 11 ms 2168 KB Output is correct
11 Correct 13 ms 2296 KB Output is correct
12 Correct 7 ms 2088 KB Output is correct
13 Correct 10 ms 2212 KB Output is correct
14 Correct 8 ms 512 KB Output is correct
15 Correct 18 ms 2176 KB Output is correct
16 Correct 41 ms 2680 KB Output is correct
17 Correct 6 ms 384 KB Output is correct
18 Partially correct 43 ms 2680 KB Partially correct - number of queries: 5358
19 Correct 5 ms 384 KB Output is correct
20 Correct 18 ms 1528 KB Output is correct
21 Correct 31 ms 2296 KB Output is correct
22 Correct 12 ms 2168 KB Output is correct
23 Correct 11 ms 2168 KB Output is correct
24 Correct 9 ms 2168 KB Output is correct
25 Correct 31 ms 2296 KB Output is correct
26 Correct 32 ms 2296 KB Output is correct
27 Correct 10 ms 2300 KB Output is correct
28 Correct 41 ms 2572 KB Output is correct
29 Correct 39 ms 2424 KB Output is correct
30 Partially correct 63 ms 2680 KB Partially correct - number of queries: 5310
31 Correct 5 ms 376 KB Output is correct
32 Correct 15 ms 2168 KB Output is correct
33 Correct 1 ms 256 KB Output is correct
34 Correct 21 ms 2424 KB Output is correct
35 Correct 11 ms 2168 KB Output is correct
36 Correct 21 ms 2300 KB Output is correct
37 Correct 14 ms 2168 KB Output is correct
38 Correct 10 ms 2168 KB Output is correct
39 Correct 30 ms 2424 KB Output is correct
40 Correct 46 ms 2552 KB Output is correct
41 Correct 33 ms 2464 KB Output is correct
42 Correct 33 ms 2424 KB Output is correct
43 Correct 33 ms 2552 KB Output is correct
44 Correct 25 ms 2296 KB Output is correct
45 Correct 19 ms 2168 KB Output is correct
46 Correct 4 ms 384 KB Output is correct
47 Correct 29 ms 2296 KB Output is correct
48 Correct 41 ms 2552 KB Output is correct
49 Correct 12 ms 2200 KB Output is correct
50 Partially correct 54 ms 2680 KB Partially correct - number of queries: 5366
51 Correct 28 ms 2296 KB Output is correct
52 Correct 11 ms 2176 KB Output is correct
53 Correct 12 ms 2168 KB Output is correct
54 Correct 25 ms 2424 KB Output is correct
55 Correct 6 ms 384 KB Output is correct
56 Partially correct 45 ms 2680 KB Partially correct - number of queries: 5347
57 Correct 45 ms 2552 KB Output is correct
58 Correct 39 ms 2552 KB Output is correct
59 Correct 42 ms 2552 KB Output is correct
60 Correct 32 ms 2424 KB Output is correct
61 Correct 11 ms 2304 KB Output is correct
62 Correct 11 ms 2168 KB Output is correct
63 Correct 10 ms 2168 KB Output is correct
64 Correct 8 ms 2080 KB Output is correct
65 Correct 10 ms 2168 KB Output is correct
66 Correct 13 ms 2464 KB Output is correct
67 Correct 10 ms 2176 KB Output is correct
68 Correct 5 ms 384 KB Output is correct
69 Correct 14 ms 2168 KB Output is correct
70 Correct 10 ms 2172 KB Output is correct
71 Partially correct 30 ms 2740 KB Partially correct - number of queries: 5143
72 Correct 13 ms 2176 KB Output is correct
73 Partially correct 49 ms 2680 KB Partially correct - number of queries: 5087
74 Partially correct 39 ms 2700 KB Partially correct - number of queries: 5111
75 Correct 11 ms 2176 KB Output is correct
76 Correct 43 ms 2552 KB Output is correct
77 Partially correct 58 ms 2684 KB Partially correct - number of queries: 5376
78 Correct 12 ms 2176 KB Output is correct
79 Correct 34 ms 2424 KB Output is correct
80 Partially correct 52 ms 2680 KB Partially correct - number of queries: 5383
81 Partially correct 42 ms 2808 KB Partially correct - number of queries: 5372
82 Partially correct 50 ms 2684 KB Partially correct - number of queries: 5333
83 Correct 10 ms 2176 KB Output is correct
84 Correct 34 ms 2560 KB Output is correct
85 Partially correct 55 ms 2680 KB Partially correct - number of queries: 5373
86 Correct 11 ms 2168 KB Output is correct
87 Correct 11 ms 2168 KB Output is correct
88 Correct 13 ms 2168 KB Output is correct
89 Correct 11 ms 2176 KB Output is correct
90 Correct 11 ms 2168 KB Output is correct
91 Correct 11 ms 2168 KB Output is correct
92 Correct 11 ms 2168 KB Output is correct
93 Correct 12 ms 2176 KB Output is correct
94 Correct 11 ms 2168 KB Output is correct
95 Correct 13 ms 2176 KB Output is correct
96 Correct 13 ms 2176 KB Output is correct
97 Correct 11 ms 2180 KB Output is correct