Submission
Status:
(%%%P%)
Score: 45
User: Namkhing
Problemset: Ice cream
Language: cpp
Time: 0.004 second
Submitted On: 2025-04-23 17:25:59
#include "ice_cream.h"
#include <bits/stdc++.h>
using namespace std;
const int seed = 1;
const double inf = 1e9;
const int N = 1510;
int n, a[N];
float dp[N];
int guess(int N) {
// write your solution here
srand(seed);
n = N;
for (int i = 2; i <= n; i++) dp[i] = n;
for (int i = 2; i <= n; i++) a[i] = i / 2;
int l = 1, r = n;
while (l < r) {
int sz = r - l + 1;
int opt = a[sz];
int b = l + opt;
int e = r - opt;
int x = rand() & 1;
if (x) {
bool f = ask(l, b - 1);
if (f) r = b - 1;
else l = b;
}
else {
bool f = ask(e + 1, r);
if (f) l = e + 1;
else r = e;
}
}
return l;
}