# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
259176 | GREGOIRELC | The Big Prize (IOI17_prize) | C++14 | 107 ms | 1420 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 <iostream>
using namespace std;
const int MAX_CADEAU = 2e5;
const int MAX_UTILE = 500;
bool estUtile[MAX_CADEAU];
bool dejaVu[MAX_CADEAU];
int resultGauche[MAX_CADEAU];
int find_best(int N)
{
int nbApelle = 0;
int maxi = 0;
for(int iCadeau = 0; iCadeau < min(MAX_UTILE, N); iCadeau++)
{
vector<int> r = ask(iCadeau);
maxi = max(maxi, r[0] + r[1]);
}
int curCadeau = 0;
while(curCadeau < N)
{
//cout << curCadeau << endl;
if(estUtile[curCadeau])
{
curCadeau++;
continue;
}
vector<int> r;
int nbGauche;
if(dejaVu[curCadeau])
{
nbGauche = resultGauche[curCadeau];
}
else
{
r = ask(curCadeau);
if(r[0] + r[1] < maxi)
{
estUtile[curCadeau] = true;
curCadeau++;
continue;
}
dejaVu[curCadeau] = true;
resultGauche[curCadeau] = r[0];
nbGauche = r[0];
}
int borneDroite = min(N - 1, curCadeau + 100);
while(curCadeau < borneDroite)
{
if(estUtile[borneDroite])
{
borneDroite--;
continue;
}
if(dejaVu[borneDroite] && resultGauche[borneDroite] == nbGauche)
{
break;
}
if(dejaVu[borneDroite] && resultGauche[borneDroite] > nbGauche)
{
borneDroite = (curCadeau + borneDroite) / 2;
continue;
}
r = ask(borneDroite);
dejaVu[borneDroite] = true;
resultGauche[borneDroite] = r[0];
if(r[0] + r[1] < maxi)
{
estUtile[borneDroite] = true;
borneDroite--;
continue;
}
if(r[0] == nbGauche)
{
break;
}
else
{
borneDroite = (curCadeau + borneDroite) / 2;
}
}
curCadeau = borneDroite + 1;
}
for(int curCadeau = 0; curCadeau < N; curCadeau++)
{
if(estUtile[curCadeau])
{
vector<int> r = ask(curCadeau);
if(r[0] + r[1] == 0)
{
return curCadeau;
}
}
}
return -1;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |