# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
390472 | Keshi | The Big Prize (IOI17_prize) | C++17 | 126 ms | 1216 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//In the name of God
#include <bits/stdc++.h>
#include "prize.h"
using namespace std;
typedef int ll;
typedef pair<ll, ll> pll;
const ll maxn = 2e5 + 100;
const ll mod = 1e9 + 7;
const ll inf = 1e9;
#define pb push_back
#define Mp make_pair
#define F first
#define S second
#define Sz(x) ll((x).size())
#define all(x) (x).begin(), (x).end()
ll p[maxn], cnt;
int find_best(int n){
srand(time(NULL));
for(ll i = 0; i < n; i++){
p[i] = i;
}
random_shuffle(p, p + n);
ll x = 0;
for(ll i = 0; i < min(480, n); i++){
auto f = ask(p[i]);
cnt++;
if(cnt == 10000) cout << 1 / 0;
x = max(x, f[0] + f[1]);
}
ll ptr = 0;
ll cnt3 = 0;
while(ptr < n){
auto f = ask(ptr);
if(f[0] + f[1] > x) cout << 1 / 0;
cnt++;
cnt3++;
if(cnt3 > 480 * 2) return -1;
if(cnt == 10000) cout << 1 / 0;
if(f[0] + f[1] == 0) return ptr;
if(f[0] + f[1] != x){
ptr++;
continue;
}
ll l = ptr, r = n;
ll cnt2 = 0;
while(r - l > 1){
ll mid = (l + r) >> 1;
auto f2 = ask(mid);
cnt2++;
cnt++;
if(cnt == 10000) cout << 1 / 0;
if(f2[0] == f[0] && f2[1] == f[1]) l = mid;
else r = mid;
}
if(cnt2 > 18) return -1;
ptr = r;
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |