# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
542988 | MilosMilutinovic | The Big Prize (IOI17_prize) | C++14 | 54 ms | 9952 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.
#include "prize.h"
#include <bits/stdc++.h>
#define SZ 200005
using namespace std;
typedef pair <int,int> P;
map <int,int> ve[SZ];
int ret=-1;
P query(int id)
{
auto v=ask(id);
return {v[0],v[1]};
}
void solve(int l,int r)
{
if(ret!=-1||l>r) return;
int mid=l+r>>1;
P v=query(mid);
int sz=v.first+v.second;
if(sz==0)
{
ret=mid;
return;
}
bool L=true,R=true;
auto it=ve[sz].upper_bound(mid);
if(it!=ve[sz].begin()&&(*prev(it)).second==v.first) L=false;
if(it!=ve[sz].end()&&(*it).second==v.first) R=false;
ve[sz][mid]=v.first;
if(L) solve(l,mid-1);
if(R) solve(mid+1,r);
}
int find_best(int n)
{
solve(0,n-1);
return ret;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |