Submission #1082306

# Submission time Handle Problem Language Result Execution time Memory
1082306 2024-08-31T06:30:08 Z MMihalev The Big Prize (IOI17_prize) C++14
0 / 100
56 ms 716 KB
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include "prize.h"
using namespace std;
const int MAX_N=2e5+4;
int asked[MAX_N][2];
bool used[MAX_N];
pair<int,int>query(int pos)
{
    if(used[pos])return {asked[pos][0],asked[pos][1]};

    used[pos]=1;
    auto ve=ask(pos);
    asked[pos][0]=ve[0];
    asked[pos][1]=ve[1];
    return {ve[0],ve[1]};
}
int find_best(int n)
{
    int prevpos=-1;
    while(1)
    {
        prevpos++;
        if(prevpos>=n)break;
        auto cur=query(prevpos);
        long long all=cur.first+cur.second;
        if(all*all>=n)
        {
            int l=prevpos,r=n-1;
            while(l<=r)
            {
                int mid=(l+r)/2;
                auto cur2=query(mid);
                if(cur2==cur)
                {
                    prevpos=mid;
                    l=mid+1;
                }
                else r=mid-1;
            }
        }
        else
        {
            if(all==0)return prevpos;
        }
    }
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 56 ms 464 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 52 ms 716 KB Incorrect
2 Halted 0 ms 0 KB -