답안 #296944

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
296944 2020-09-11T05:30:12 Z kshitij_sodani 커다란 상품 (IOI17_prize) C++14
100 / 100
94 ms 47632 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define a first
#define b second
#define pb push_back


#include "prize.h"
vector<int> pre[2000001];
pair<int,int> ma={-1,-1};
int ans;
vector<int> ask2(int i){
	if(pre[i].size()>0){
		return pre[i];
	}
	pre[i]=ask(i);
	return pre[i];
}
void run(int l,int r,int aa,int bb){
	if(aa+bb==ma.a){
		return ;
	}
	if(l>r){
		return;
	}
	//cout<<l<<":"<<r<<":"<<aa<<":"<<bb<<endl;
	int mid=(l+r)/2;
	int xx=0;
	for(int i=mid;i>=l;i--){
		vector<int> res=ask2(i);
		if(res[0]+res[1]==ma.a){
			if(i>l){
				run(l,i-1,aa,res[1]);
			}
			if(mid<r){
				run(mid+1,r,res[0]+xx,bb);
			}
			return;
		}
		xx++;
	}
	if(mid<r){
		run(mid+1,r,aa+xx,bb);
	}
}
int find_best(int n) {
	
	for(int i=0;i<min(500,n);i++){
		vector<int> res=ask2(i);
		if(res[0]+res[1]>ma.a){
			ma={res[0]+res[1],i};
		}
		if(ma.a>100){
			break;
		}
	}
	run(0,n-1,0,0);

	for(int i=0;i<n;i++){
		if(pre[i].size()>0){
			if(pre[i][0]+pre[i][1]==0){
				return i;
			}
		}
	}




	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 47224 KB Output is correct
2 Correct 40 ms 47232 KB Output is correct
3 Correct 37 ms 47232 KB Output is correct
4 Correct 39 ms 47404 KB Output is correct
5 Correct 42 ms 47224 KB Output is correct
6 Correct 38 ms 47252 KB Output is correct
7 Correct 39 ms 47352 KB Output is correct
8 Correct 42 ms 47232 KB Output is correct
9 Correct 37 ms 47264 KB Output is correct
10 Correct 40 ms 47232 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 47224 KB Output is correct
2 Correct 38 ms 47224 KB Output is correct
3 Correct 38 ms 47232 KB Output is correct
4 Correct 39 ms 47232 KB Output is correct
5 Correct 37 ms 47232 KB Output is correct
6 Correct 35 ms 47336 KB Output is correct
7 Correct 38 ms 47352 KB Output is correct
8 Correct 39 ms 47232 KB Output is correct
9 Correct 36 ms 47256 KB Output is correct
10 Correct 39 ms 47232 KB Output is correct
11 Correct 42 ms 47352 KB Output is correct
12 Correct 42 ms 47352 KB Output is correct
13 Correct 43 ms 47340 KB Output is correct
14 Correct 41 ms 47360 KB Output is correct
15 Correct 75 ms 47424 KB Output is correct
16 Correct 76 ms 47356 KB Output is correct
17 Correct 81 ms 47392 KB Output is correct
18 Correct 74 ms 47352 KB Output is correct
19 Correct 70 ms 47484 KB Output is correct
20 Correct 61 ms 47480 KB Output is correct
21 Correct 87 ms 47352 KB Output is correct
22 Correct 68 ms 47416 KB Output is correct
23 Correct 38 ms 47348 KB Output is correct
24 Correct 42 ms 47364 KB Output is correct
25 Correct 75 ms 47440 KB Output is correct
26 Correct 69 ms 47352 KB Output is correct
27 Correct 38 ms 47232 KB Output is correct
28 Correct 69 ms 47432 KB Output is correct
29 Correct 75 ms 47404 KB Output is correct
30 Correct 86 ms 47476 KB Output is correct
31 Correct 57 ms 47468 KB Output is correct
32 Correct 46 ms 47352 KB Output is correct
33 Correct 33 ms 47224 KB Output is correct
34 Correct 62 ms 47544 KB Output is correct
35 Correct 41 ms 47264 KB Output is correct
36 Correct 85 ms 47552 KB Output is correct
37 Correct 45 ms 47352 KB Output is correct
38 Correct 42 ms 47232 KB Output is correct
39 Correct 60 ms 47460 KB Output is correct
40 Correct 78 ms 47352 KB Output is correct
41 Correct 83 ms 47568 KB Output is correct
42 Correct 77 ms 47360 KB Output is correct
43 Correct 57 ms 47460 KB Output is correct
44 Correct 89 ms 47352 KB Output is correct
45 Correct 78 ms 47352 KB Output is correct
46 Correct 59 ms 47632 KB Output is correct
47 Correct 81 ms 47368 KB Output is correct
48 Correct 74 ms 47452 KB Output is correct
49 Correct 79 ms 47384 KB Output is correct
50 Correct 94 ms 47352 KB Output is correct
51 Correct 75 ms 47444 KB Output is correct
52 Correct 92 ms 47352 KB Output is correct
53 Correct 40 ms 47232 KB Output is correct
54 Correct 74 ms 47360 KB Output is correct
55 Correct 87 ms 47352 KB Output is correct
56 Correct 81 ms 47352 KB Output is correct
57 Correct 74 ms 47500 KB Output is correct
58 Correct 62 ms 47472 KB Output is correct
59 Correct 71 ms 47356 KB Output is correct
60 Correct 68 ms 47352 KB Output is correct
61 Correct 40 ms 47360 KB Output is correct
62 Correct 36 ms 47376 KB Output is correct
63 Correct 42 ms 47264 KB Output is correct
64 Correct 38 ms 47232 KB Output is correct
65 Correct 38 ms 47232 KB Output is correct
66 Correct 37 ms 47352 KB Output is correct
67 Correct 38 ms 47352 KB Output is correct
68 Correct 37 ms 47224 KB Output is correct
69 Correct 39 ms 47232 KB Output is correct
70 Correct 36 ms 47232 KB Output is correct
71 Correct 86 ms 47356 KB Output is correct
72 Correct 43 ms 47352 KB Output is correct
73 Correct 73 ms 47480 KB Output is correct
74 Correct 70 ms 47352 KB Output is correct
75 Correct 40 ms 47360 KB Output is correct
76 Correct 78 ms 47352 KB Output is correct
77 Correct 74 ms 47480 KB Output is correct
78 Correct 44 ms 47352 KB Output is correct
79 Correct 55 ms 47356 KB Output is correct
80 Correct 76 ms 47352 KB Output is correct
81 Correct 68 ms 47480 KB Output is correct
82 Correct 70 ms 47352 KB Output is correct
83 Correct 40 ms 47224 KB Output is correct
84 Correct 78 ms 47352 KB Output is correct
85 Correct 86 ms 47480 KB Output is correct
86 Correct 39 ms 47232 KB Output is correct
87 Correct 38 ms 47232 KB Output is correct
88 Correct 35 ms 47232 KB Output is correct
89 Correct 36 ms 47224 KB Output is correct
90 Correct 37 ms 47232 KB Output is correct
91 Correct 35 ms 47232 KB Output is correct
92 Correct 40 ms 47232 KB Output is correct
93 Correct 40 ms 47360 KB Output is correct
94 Correct 42 ms 47352 KB Output is correct
95 Correct 42 ms 47480 KB Output is correct
96 Correct 40 ms 47360 KB Output is correct
97 Correct 38 ms 47308 KB Output is correct