#include "grader.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
ll l,r,res,ans;
void calc(ll lst){
// cout << l << ' ' << r << endl;
if(l >= r){
ans = l;
return;
}
ll md1 = l + (r - l) / 3;
ll md2 = r - (r - l) / 3;
if(abs(md1 - lst) < abs(md2 - lst))
swap(md1,md2);
res = Guess(md1);
if(res == 1){
if(lst > md1){
r = min(r,(md1+lst)/2);
}else{
l = max(l,(md1+lst)/2+1);
}
}else if(res == -1){
if(lst > md1){
l = max(l,(md1+lst)/2+1);
}else{
r = min(r,(md1+lst)/2);
}
}else{
ans = (md1+lst)/2;
return;
}
calc(md1);
}
int HC(int N){
l = 1;
r = N;
ll md1 = l + (r - l) / 3;
Guess(md1);
calc(md1);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
35 ms |
1272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
35 ms |
1272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
1272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
927 ms |
8272 KB |
Output is partially correct - alpha = 0.333333333333 |