답안 #69477

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
69477 2018-08-21T02:28:16 Z Diuven 커다란 상품 (IOI17_prize) C++14
20 / 100
86 ms 2380 KB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
const int MX=200010;

bool up[MX];
int L[MX], R[MX], sum, n, ans;

void my_ask(int i){
	static set<int> S;
	if(S.find(i)!=S.end()) return;
	S.insert(i);
	vi now=ask(i);
	L[i]=now[0], R[i]=now[1];
}

void search(int s, int e, int lc, int mc, int rc){
	if(s>e || mc==0) return;
	assert(mc>=0);

	int m=(s+e)/2;

	for(int i=m; i<=e; i++){
		my_ask(i);
		if(L[i]+R[i]==0){ ans=i; return; }
		if(L[i]+R[i]==sum){
			search(s,m-1, lc, L[i]-(i-m)-lc, R[i]+i-m);
			search(i+1,e, L[i], R[i]-rc, rc);
			return;
		}
	}
	for(int i=m; i>=s; i--){
		my_ask(i);
		if(L[i]+R[i]==0){ ans=i; return; }
		if(L[i]+R[i]==sum){
			search(s,i-1, lc, L[i]-lc, R[i]);
			return;
		}
	}
}

void get(){
	srand(time(NULL));
	for(int i=0; i<20; i++){
		int x=rand()%n; my_ask(x);
		sum=max(sum, L[x]+R[x]);
	}
}

int find_best(int _n){
	n=_n;
	get();
	ans=-1;
	search(0,n-1,0,sum,0);
	assert(ans>=0 && L[ans]==0 && R[ans]==0);
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 2 ms 568 KB Output is correct
3 Correct 4 ms 624 KB Output is correct
4 Correct 3 ms 664 KB Output is correct
5 Correct 2 ms 664 KB Output is correct
6 Correct 3 ms 664 KB Output is correct
7 Correct 4 ms 664 KB Output is correct
8 Correct 3 ms 664 KB Output is correct
9 Correct 2 ms 688 KB Output is correct
10 Correct 4 ms 692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 700 KB Output is correct
2 Correct 2 ms 732 KB Output is correct
3 Correct 2 ms 732 KB Output is correct
4 Correct 3 ms 828 KB Output is correct
5 Correct 2 ms 828 KB Output is correct
6 Correct 3 ms 828 KB Output is correct
7 Correct 3 ms 828 KB Output is correct
8 Correct 4 ms 828 KB Output is correct
9 Correct 2 ms 828 KB Output is correct
10 Correct 3 ms 828 KB Output is correct
11 Correct 6 ms 1456 KB Output is correct
12 Correct 7 ms 1468 KB Output is correct
13 Correct 9 ms 1468 KB Output is correct
14 Correct 17 ms 1468 KB Output is correct
15 Correct 40 ms 2236 KB Output is correct
16 Correct 53 ms 2236 KB Output is correct
17 Correct 38 ms 2272 KB Output is correct
18 Correct 53 ms 2380 KB Output is correct
19 Correct 66 ms 2380 KB Output is correct
20 Correct 29 ms 2380 KB Output is correct
21 Correct 46 ms 2380 KB Output is correct
22 Correct 33 ms 2380 KB Output is correct
23 Correct 5 ms 2380 KB Output is correct
24 Correct 6 ms 2380 KB Output is correct
25 Correct 34 ms 2380 KB Output is correct
26 Correct 40 ms 2380 KB Output is correct
27 Correct 4 ms 2380 KB Output is correct
28 Correct 44 ms 2380 KB Output is correct
29 Correct 48 ms 2380 KB Output is correct
30 Correct 49 ms 2380 KB Output is correct
31 Correct 55 ms 2380 KB Output is correct
32 Correct 8 ms 2380 KB Output is correct
33 Correct 4 ms 2380 KB Output is correct
34 Correct 54 ms 2380 KB Output is correct
35 Correct 6 ms 2380 KB Output is correct
36 Correct 21 ms 2380 KB Output is correct
37 Correct 6 ms 2380 KB Output is correct
38 Correct 4 ms 2380 KB Output is correct
39 Correct 40 ms 2380 KB Output is correct
40 Correct 31 ms 2380 KB Output is correct
41 Correct 35 ms 2380 KB Output is correct
42 Correct 45 ms 2380 KB Output is correct
43 Correct 44 ms 2380 KB Output is correct
44 Correct 37 ms 2380 KB Output is correct
45 Correct 56 ms 2380 KB Output is correct
46 Correct 64 ms 2380 KB Output is correct
47 Correct 35 ms 2380 KB Output is correct
48 Correct 42 ms 2380 KB Output is correct
49 Correct 40 ms 2380 KB Output is correct
50 Correct 53 ms 2380 KB Output is correct
51 Correct 39 ms 2380 KB Output is correct
52 Correct 35 ms 2380 KB Output is correct
53 Correct 4 ms 2380 KB Output is correct
54 Correct 46 ms 2380 KB Output is correct
55 Correct 62 ms 2380 KB Output is correct
56 Correct 41 ms 2380 KB Output is correct
57 Correct 40 ms 2380 KB Output is correct
58 Correct 40 ms 2380 KB Output is correct
59 Correct 47 ms 2380 KB Output is correct
60 Correct 41 ms 2380 KB Output is correct
61 Correct 4 ms 2380 KB Output is correct
62 Correct 3 ms 2380 KB Output is correct
63 Correct 3 ms 2380 KB Output is correct
64 Correct 3 ms 2380 KB Output is correct
65 Correct 3 ms 2380 KB Output is correct
66 Correct 6 ms 2380 KB Output is correct
67 Correct 7 ms 2380 KB Output is correct
68 Correct 3 ms 2380 KB Output is correct
69 Correct 7 ms 2380 KB Output is correct
70 Correct 6 ms 2380 KB Output is correct
71 Correct 43 ms 2380 KB Output is correct
72 Correct 7 ms 2380 KB Output is correct
73 Correct 36 ms 2380 KB Output is correct
74 Correct 31 ms 2380 KB Output is correct
75 Correct 4 ms 2380 KB Output is correct
76 Correct 24 ms 2380 KB Output is correct
77 Correct 49 ms 2380 KB Output is correct
78 Correct 8 ms 2380 KB Output is correct
79 Correct 24 ms 2380 KB Output is correct
80 Correct 58 ms 2380 KB Output is correct
81 Correct 50 ms 2380 KB Output is correct
82 Correct 45 ms 2380 KB Output is correct
83 Correct 4 ms 2380 KB Output is correct
84 Correct 43 ms 2380 KB Output is correct
85 Correct 51 ms 2380 KB Output is correct
86 Incorrect 86 ms 2380 KB Incorrect
87 Halted 0 ms 0 KB -