답안 #520695

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
520695 2022-01-30T21:06:08 Z d4xn 커다란 상품 (IOI17_prize) C++17
20 / 100
74 ms 344 KB
#include "prize.h"
#include <vector>
using namespace std;

int search(int l, int r) {
	if (l > r) return -1;
	if (l == r) {
		vector<int> ans = ask(l);
		if (ans[0] == 0 && ans[1] == 0) return l;
		return -1;
	}
	
	int m = (l+r)/2;
	vector<int> ans = ask(m);
	if (ans[0] == 0 && ans[1] == 0) return m;
	
	if (ans[0] == 0) {
		return search(m+1, r);
	}
	else if (ans[1] == 0) {
		return search(l, m-1);
	}
	else {
		int ans1, ans2;
		ans1 = search(l, m-1);
		ans2 = search(m+1, r);
		return (ans1 == -1 ? ans2 : ans1);
	}

	return -1;
}

int find_best(int n) {
	return search(0, n-1);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 284 KB Output is correct
2 Correct 1 ms 284 KB Output is correct
3 Correct 1 ms 268 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 200 KB Output is correct
6 Correct 1 ms 284 KB Output is correct
7 Correct 1 ms 200 KB Output is correct
8 Correct 1 ms 280 KB Output is correct
9 Correct 1 ms 200 KB Output is correct
10 Correct 1 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 284 KB Output is correct
3 Correct 1 ms 284 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 1 ms 280 KB Output is correct
6 Correct 1 ms 288 KB Output is correct
7 Correct 1 ms 200 KB Output is correct
8 Correct 1 ms 200 KB Output is correct
9 Correct 1 ms 284 KB Output is correct
10 Correct 1 ms 200 KB Output is correct
11 Incorrect 74 ms 284 KB Incorrect
12 Halted 0 ms 0 KB -