답안 #226572

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
226572 2020-04-24T10:58:17 Z Blerargh Hotter Colder (IOI10_hottercolder) C++17
0 / 100
10000 ms 24628 KB
#include "grader.h"
#include <bits/stdc++.h>
using namespace std;

int HC(int N){
	if (N==1) return 1;
	
	int nextguess, prevvguess;
	int l=1, r=N;
	
	int mid = (l+r)/2;
	int chk = Guess(mid);
	chk = Guess(mid+1);
	if (chk == -1){
		r = mid;
	} else if (chk == 1){
		l = mid+1;
	}
	prevvguess = mid+1;
	
	while (l<r){
		nextguess = l - prevvguess + r;
		if (nextguess > prevvguess) nextguess = min(nextguess, N);
		else if (nextguess < prevvguess) nextguess = max(0, nextguess);
		chk = Guess(nextguess);
		
		if (chk == -1){
			if (nextguess > prevvguess) {
				r = (nextguess + prevvguess)/2;
			} else {
				l = (nextguess + prevvguess)/2;
			}
		} else if (chk == 1){
			if (nextguess > prevvguess) {
				l = (nextguess + prevvguess)/2;
			} else {
				r = (nextguess + prevvguess)/2;
			}
		} else if (chk == 0){
			return (prevvguess+nextguess)/2;
		}
		prevvguess = nextguess;
	}
}

Compilation message

hottercolder.cpp: In function 'int HC(int)':
hottercolder.cpp:44:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 10048 ms 1280 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 10042 ms 1280 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 10061 ms 1280 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 10050 ms 24628 KB Time limit exceeded