답안 #524855

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
524855 2022-02-10T06:57:33 Z CSQ31 커다란 상품 (IOI17_prize) C++17
100 / 100
62 ms 6008 KB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
int num = 0;
#define sz(a) (int)(a.size());
vector<int>res[200000];
int cnt = 0;
int solve(int l,int r,int lf = 0,int rg = 0){
	if(l > r)return -1;
	int mid = (l+r)/2;
	for(int i=0;i<=r-l;i++){
		int ml = mid-i/2;
		int mr = mid+(i+1)/2;
		int m = i%2==0?ml : mr;
		int tmpl = i%2==0?0:mr-ml;
		int tmpr = i%2==1?0:mr-ml;
		res[m] = ask(m);
		if(!res[m][0] && !res[m][1])return m;
		if(res[m][0] + res[m][1] == num){
			int c = -1;
		     if(res[m][0]-tmpl>lf)c = max(c,solve(l,ml-1,lf,res[m][1]+tmpl));
	         if(res[m][1]-tmpr>rg)c = max(c,solve(mr+1,r,res[m][0]+tmpr,rg));
	         return c;
	         
		}
	}
	return -1;
		
}
int find_best(int n) {
	vector<int>a(n);
	for(int i=0;i<n;i++)a[i] = i;
	int p = 0;
	for(int i=0;i<min(n,(int)(sqrt(n)+30)) && num < 27;i++){
		vector<int>res = ask(i);
		if(!res[0] && !res[1])return i;
		if(res[0] + res[1] > num){
			num = res[0] + res[1];
			p = i;
		}
	}
	
	//d&c to try all small guys since < #small guys < sqrt(n)
	return solve(p,n-1,p,0);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 5744 KB Output is correct
2 Correct 8 ms 5704 KB Output is correct
3 Correct 6 ms 5752 KB Output is correct
4 Correct 8 ms 5744 KB Output is correct
5 Correct 7 ms 5752 KB Output is correct
6 Correct 3 ms 5704 KB Output is correct
7 Correct 6 ms 5744 KB Output is correct
8 Correct 7 ms 5752 KB Output is correct
9 Correct 7 ms 5704 KB Output is correct
10 Correct 9 ms 5704 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 5748 KB Output is correct
2 Correct 8 ms 5704 KB Output is correct
3 Correct 6 ms 5748 KB Output is correct
4 Correct 10 ms 5704 KB Output is correct
5 Correct 6 ms 5748 KB Output is correct
6 Correct 3 ms 5752 KB Output is correct
7 Correct 7 ms 5756 KB Output is correct
8 Correct 7 ms 5748 KB Output is correct
9 Correct 8 ms 5752 KB Output is correct
10 Correct 9 ms 5704 KB Output is correct
11 Correct 8 ms 5744 KB Output is correct
12 Correct 8 ms 5748 KB Output is correct
13 Correct 5 ms 5800 KB Output is correct
14 Correct 6 ms 5076 KB Output is correct
15 Correct 42 ms 5824 KB Output is correct
16 Correct 41 ms 5904 KB Output is correct
17 Correct 37 ms 5868 KB Output is correct
18 Correct 39 ms 5812 KB Output is correct
19 Correct 49 ms 5824 KB Output is correct
20 Correct 31 ms 5440 KB Output is correct
21 Correct 37 ms 5792 KB Output is correct
22 Correct 17 ms 5880 KB Output is correct
23 Correct 8 ms 5752 KB Output is correct
24 Correct 7 ms 5732 KB Output is correct
25 Correct 32 ms 5804 KB Output is correct
26 Correct 49 ms 5804 KB Output is correct
27 Correct 6 ms 5780 KB Output is correct
28 Correct 19 ms 5972 KB Output is correct
29 Correct 32 ms 5840 KB Output is correct
30 Correct 37 ms 5868 KB Output is correct
31 Correct 49 ms 5800 KB Output is correct
32 Correct 7 ms 5744 KB Output is correct
33 Correct 3 ms 4936 KB Output is correct
34 Correct 22 ms 5904 KB Output is correct
35 Correct 9 ms 5748 KB Output is correct
36 Correct 38 ms 5824 KB Output is correct
37 Correct 7 ms 5748 KB Output is correct
38 Correct 11 ms 5740 KB Output is correct
39 Correct 42 ms 5996 KB Output is correct
40 Correct 39 ms 5792 KB Output is correct
41 Correct 46 ms 5824 KB Output is correct
42 Correct 37 ms 5984 KB Output is correct
43 Correct 36 ms 5864 KB Output is correct
44 Correct 27 ms 5900 KB Output is correct
45 Correct 41 ms 5792 KB Output is correct
46 Correct 23 ms 5904 KB Output is correct
47 Correct 33 ms 5860 KB Output is correct
48 Correct 46 ms 5828 KB Output is correct
49 Correct 42 ms 5812 KB Output is correct
50 Correct 45 ms 5792 KB Output is correct
51 Correct 47 ms 5824 KB Output is correct
52 Correct 37 ms 5812 KB Output is correct
53 Correct 8 ms 5748 KB Output is correct
54 Correct 33 ms 6008 KB Output is correct
55 Correct 32 ms 5796 KB Output is correct
56 Correct 42 ms 5872 KB Output is correct
57 Correct 46 ms 5820 KB Output is correct
58 Correct 27 ms 5908 KB Output is correct
59 Correct 49 ms 5812 KB Output is correct
60 Correct 40 ms 5892 KB Output is correct
61 Correct 8 ms 5768 KB Output is correct
62 Correct 5 ms 5792 KB Output is correct
63 Correct 10 ms 5704 KB Output is correct
64 Correct 6 ms 5868 KB Output is correct
65 Correct 5 ms 5756 KB Output is correct
66 Correct 5 ms 5796 KB Output is correct
67 Correct 4 ms 5796 KB Output is correct
68 Correct 9 ms 5752 KB Output is correct
69 Correct 8 ms 5696 KB Output is correct
70 Correct 5 ms 5872 KB Output is correct
71 Correct 49 ms 5924 KB Output is correct
72 Correct 7 ms 5704 KB Output is correct
73 Correct 43 ms 5808 KB Output is correct
74 Correct 37 ms 5860 KB Output is correct
75 Correct 9 ms 5704 KB Output is correct
76 Correct 62 ms 5828 KB Output is correct
77 Correct 51 ms 5892 KB Output is correct
78 Correct 7 ms 5804 KB Output is correct
79 Correct 26 ms 5924 KB Output is correct
80 Correct 45 ms 5808 KB Output is correct
81 Correct 46 ms 5828 KB Output is correct
82 Correct 50 ms 5952 KB Output is correct
83 Correct 7 ms 5796 KB Output is correct
84 Correct 39 ms 5812 KB Output is correct
85 Correct 48 ms 5896 KB Output is correct
86 Correct 8 ms 5704 KB Output is correct
87 Correct 4 ms 5704 KB Output is correct
88 Correct 5 ms 5752 KB Output is correct
89 Correct 8 ms 5704 KB Output is correct
90 Correct 8 ms 5704 KB Output is correct
91 Correct 7 ms 5748 KB Output is correct
92 Correct 8 ms 5704 KB Output is correct
93 Correct 10 ms 5704 KB Output is correct
94 Correct 12 ms 5784 KB Output is correct
95 Correct 10 ms 5704 KB Output is correct
96 Correct 10 ms 5800 KB Output is correct
97 Correct 8 ms 5704 KB Output is correct