#include "grader.h"
int HC(int N){
if (N == 1)return N;
int left = 1;
int right = N;
Guess(1);
if (N == 2) {
if (Guess(2) == 1)return 2;
return 1;
}
int mid = (left + right) / 2;
while (left < right) {
mid = (left + right) / 2;
int query = Guess(mid);
if (query == 1) {//hotter
left = mid+1;
}
else if (query == -1) {//colder
right = mid-1;
}
else {// same
right = mid - 1;
left = left + 1;
}
}
if (right < left) {
Guess(right);
while (right > 1) {
if (Guess(right - 1) == -1)return right;
right--;
}
return right;
}
else {
Guess(left);
while (left > 1) {
if (Guess(left - 1) == -1)return left;
left--;
}
return left;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
46 ms |
1400 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
57 ms |
1272 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
48 ms |
1272 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
10090 ms |
8056 KB |
Time limit exceeded |