#include "prize.h"
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
int L,R,j,b[202020],C,nx,ma;
vector<int> d[202020];
int find_best(int n) {
vector<pair<int,vector<int> > > v;
for(int i = 0; i < n; i++)
{
L=i+1;
R=n-1;
vector<int> res;
if(b[i]==1)res=d[i];
else res=ask(i);
b[i]=1;
d[i]=res;
ma=max(ma,res[0]+res[1]);
if(res[0] + res[1] == 0)return i;
if(res[0]+res[1]<sqrt(n))continue;
for(j=0;j<v.size();j++)
if(v[j].se==res)
L=v[j].fi+1;
for(j=0;j<v.size();j++)
if(v[j].se!=res&&v[j].fi>i)
{
R=v[j].fi;
break;
}
nx=L;
while(L<R)
{
C=(L+R)/2;
vector<int> temp;
if(b[C])temp=d[C];
else temp=ask(C);
if(!b[C])
v.pb(mp(C,temp));
if(temp[0]+temp[1]==0)return C;
b[C]=1;
d[C]=temp;
ma=max(ma,temp[0]+temp[1]);
if(temp==res)
{
nx=C;
L=C+1;
}
else
R=C-1;
}
sort(v.begin(),v.end());
i=nx;
}
return 0;
}
Compilation message
prize.cpp: In function 'int find_best(int)':
prize.cpp:25:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(j=0;j<v.size();j++)
~^~~~~~~~~
prize.cpp:28:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(j=0;j<v.size();j++)
~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
62 ms |
5440 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
53 ms |
5456 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |