답안 #43124

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
43124 2018-03-09T09:54:41 Z RayaBurong25_1 커다란 상품 (IOI17_prize) C++14
20 / 100
14 ms 4364 KB
#include "prize.h"
#include <stdio.h>
#include <vector>
#include <algorithm>
int L[200005], R[200005];
int V[200005];
int min(int a, int b)
{
	return (a < b)?a:b;
}
int max(int a, int b)
{
	return (a > b)?a:b;
}
int find_best(int n) {
	int i;
	for (i = 0; i < n; i++)
		L[i] = -1;
	int mn, md, mx;
	//first sig
	std::vector<int> r;
	r = ask(0);
	L[0] = r[0];
	R[0] = r[1];
	if (R[0] == 0)
		return 0;
	int sig = 0;
	while (1)
	{
		mn = sig;
		mx = n;
		while (mx != mn)
		{
			if (mx - mn == 1)
			{
				sig = mx;
				break;
			}
			md = (mn + mx)/2;
			if (L[md] == -1)
			{
				r = ask(md);
				L[md] = r[0];
				R[md] = r[1];
			}
			if (L[md] == L[sig] && R[md] == R[sig])
				mn = md;
			else
				mx = md;
		}
		if (sig == n)
			break;
		if (L[sig] == -1)
		{
			r = ask(sig);
			L[sig] = r[0];
			R[sig] = r[1];
		}
		if (L[sig] == 0 && R[sig] == 0)
			return sig;
	}
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:62:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4364 KB Output is correct
2 Correct 0 ms 4364 KB Output is correct
3 Correct 0 ms 4364 KB Output is correct
4 Correct 1 ms 4364 KB Output is correct
5 Correct 1 ms 4364 KB Output is correct
6 Correct 1 ms 4364 KB Output is correct
7 Correct 1 ms 4364 KB Output is correct
8 Correct 0 ms 4364 KB Output is correct
9 Correct 1 ms 4364 KB Output is correct
10 Correct 1 ms 4364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4364 KB Output is correct
2 Correct 1 ms 4364 KB Output is correct
3 Correct 0 ms 4364 KB Output is correct
4 Correct 0 ms 4364 KB Output is correct
5 Correct 1 ms 4364 KB Output is correct
6 Correct 1 ms 4364 KB Output is correct
7 Correct 1 ms 4364 KB Output is correct
8 Correct 0 ms 4364 KB Output is correct
9 Correct 1 ms 4364 KB Output is correct
10 Correct 0 ms 4364 KB Output is correct
11 Correct 1 ms 4364 KB Output is correct
12 Correct 1 ms 4364 KB Output is correct
13 Correct 14 ms 4364 KB Output is correct
14 Correct 2 ms 4364 KB Output is correct
15 Correct 5 ms 4364 KB Output is correct
16 Incorrect 11 ms 4364 KB Incorrect
17 Halted 0 ms 0 KB -