답안 #96380

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
96380 2019-02-08T21:39:10 Z figter001 커다란 상품 (IOI17_prize) C++14
100 / 100
67 ms 10284 KB
#include "prize.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const int maxn = 2e5+50;

int ans,n;
map<int,vector<int>> mp[maxn];

void solve(int l,int r){
	if(l > r || ans != -1)return;
	int md = (l+r)/2;
	vector<int> res = ask(md);
	if(res[0] + res[1] == 0){
		ans = md;
		return;
	}
	int sum = res[0] + res[1];
	auto it = mp[sum].upper_bound(md);
	bool x=1,y=1;
	if(it != mp[sum].end()){
		if(it->second[0] == res[0])
			x = 0;
	}
	if(it != mp[sum].begin())
		it--;
	if(it != mp[sum].begin()){
		if(it->second[1] == res[1])
			y = 0;
	}
	mp[sum][md] = res;
	if(y)solve(l,md-1);
	if(x)solve(md+1,r);
}

int find_best(int N) {
	n = N;
	ans = -1;
	solve(0,n-1);
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 9592 KB Output is correct
2 Correct 11 ms 9720 KB Output is correct
3 Correct 12 ms 9728 KB Output is correct
4 Correct 10 ms 9728 KB Output is correct
5 Correct 11 ms 9788 KB Output is correct
6 Correct 10 ms 9592 KB Output is correct
7 Correct 18 ms 9728 KB Output is correct
8 Correct 11 ms 9720 KB Output is correct
9 Correct 10 ms 9720 KB Output is correct
10 Correct 13 ms 9592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 9720 KB Output is correct
2 Correct 11 ms 9640 KB Output is correct
3 Correct 11 ms 9720 KB Output is correct
4 Correct 10 ms 9720 KB Output is correct
5 Correct 10 ms 9728 KB Output is correct
6 Correct 10 ms 9856 KB Output is correct
7 Correct 10 ms 9720 KB Output is correct
8 Correct 10 ms 9592 KB Output is correct
9 Correct 11 ms 9848 KB Output is correct
10 Correct 9 ms 9712 KB Output is correct
11 Correct 13 ms 9720 KB Output is correct
12 Correct 11 ms 9796 KB Output is correct
13 Correct 12 ms 9756 KB Output is correct
14 Correct 12 ms 9720 KB Output is correct
15 Correct 17 ms 9720 KB Output is correct
16 Correct 60 ms 10152 KB Output is correct
17 Correct 10 ms 9720 KB Output is correct
18 Correct 50 ms 10164 KB Output is correct
19 Correct 10 ms 9720 KB Output is correct
20 Correct 28 ms 9720 KB Output is correct
21 Correct 28 ms 9848 KB Output is correct
22 Correct 15 ms 9720 KB Output is correct
23 Correct 10 ms 9592 KB Output is correct
24 Correct 10 ms 9720 KB Output is correct
25 Correct 33 ms 9896 KB Output is correct
26 Correct 19 ms 9956 KB Output is correct
27 Correct 13 ms 9720 KB Output is correct
28 Correct 25 ms 10112 KB Output is correct
29 Correct 28 ms 10196 KB Output is correct
30 Correct 28 ms 10224 KB Output is correct
31 Correct 10 ms 9592 KB Output is correct
32 Correct 17 ms 9720 KB Output is correct
33 Correct 9 ms 9640 KB Output is correct
34 Correct 25 ms 9848 KB Output is correct
35 Correct 11 ms 9720 KB Output is correct
36 Correct 22 ms 9748 KB Output is correct
37 Correct 10 ms 9732 KB Output is correct
38 Correct 11 ms 9592 KB Output is correct
39 Correct 34 ms 9848 KB Output is correct
40 Correct 52 ms 10104 KB Output is correct
41 Correct 48 ms 9976 KB Output is correct
42 Correct 33 ms 9924 KB Output is correct
43 Correct 20 ms 9944 KB Output is correct
44 Correct 27 ms 9976 KB Output is correct
45 Correct 29 ms 9848 KB Output is correct
46 Correct 10 ms 9592 KB Output is correct
47 Correct 29 ms 9848 KB Output is correct
48 Correct 36 ms 10068 KB Output is correct
49 Correct 13 ms 9740 KB Output is correct
50 Correct 59 ms 10104 KB Output is correct
51 Correct 29 ms 9976 KB Output is correct
52 Correct 11 ms 9720 KB Output is correct
53 Correct 12 ms 9720 KB Output is correct
54 Correct 36 ms 10028 KB Output is correct
55 Correct 10 ms 9592 KB Output is correct
56 Correct 28 ms 10204 KB Output is correct
57 Correct 22 ms 10076 KB Output is correct
58 Correct 45 ms 9976 KB Output is correct
59 Correct 35 ms 9992 KB Output is correct
60 Correct 20 ms 9948 KB Output is correct
61 Correct 11 ms 9732 KB Output is correct
62 Correct 10 ms 9592 KB Output is correct
63 Correct 10 ms 9860 KB Output is correct
64 Correct 11 ms 9732 KB Output is correct
65 Correct 11 ms 9592 KB Output is correct
66 Correct 11 ms 9636 KB Output is correct
67 Correct 9 ms 9720 KB Output is correct
68 Correct 9 ms 9592 KB Output is correct
69 Correct 9 ms 9592 KB Output is correct
70 Correct 10 ms 9728 KB Output is correct
71 Correct 56 ms 10104 KB Output is correct
72 Correct 18 ms 9720 KB Output is correct
73 Correct 57 ms 10284 KB Output is correct
74 Correct 67 ms 10120 KB Output is correct
75 Correct 10 ms 9720 KB Output is correct
76 Correct 56 ms 10144 KB Output is correct
77 Correct 54 ms 10108 KB Output is correct
78 Correct 16 ms 9720 KB Output is correct
79 Correct 35 ms 9848 KB Output is correct
80 Correct 53 ms 10104 KB Output is correct
81 Correct 63 ms 10132 KB Output is correct
82 Correct 39 ms 10132 KB Output is correct
83 Correct 15 ms 9712 KB Output is correct
84 Correct 48 ms 10096 KB Output is correct
85 Correct 54 ms 10148 KB Output is correct
86 Correct 17 ms 9896 KB Output is correct
87 Correct 14 ms 9720 KB Output is correct
88 Correct 18 ms 9720 KB Output is correct
89 Correct 16 ms 9720 KB Output is correct
90 Correct 10 ms 9720 KB Output is correct
91 Correct 14 ms 9720 KB Output is correct
92 Correct 10 ms 9592 KB Output is correct
93 Correct 13 ms 9720 KB Output is correct
94 Correct 12 ms 9720 KB Output is correct
95 Correct 12 ms 9720 KB Output is correct
96 Correct 12 ms 9720 KB Output is correct
97 Correct 11 ms 9720 KB Output is correct