#include "koala.h"
#include<bits/stdc++.h>
using namespace std;
int b[105],r[105];
bool viz[105];
int minValue(int n,int w)
{
int i;
for(i=0;i<n;i++)
b[i]=0;
b[0]=1;
playRound(b,r);
for(i=0;i<n;i++)
if (r[i]==0)
return i;
return 0;
}
int maxValue(int n,int w)
{
int buck=n;
int i;
for(i=0;i<n;i++)
viz[i]=0;
while(buck>1){
int cost=min(13,w/buck);
for(i=0;i<n;i++)
if (viz[i]==0)
b[i]=cost;
else
b[i]=0;
playRound(b,r);
for(i=0;i<n;i++)
if (viz[i]==0 && r[i]<=b[i])
viz[i]=1;
buck=0;
for(i=0;i<n;i++)
if (viz[i]==0)
buck++;
}
for(i=0;i<n;i++)
if (viz[i]==0)
return i;
return 0;
}
int p1=0,p2=1;
int greaterValue(int n,int w)
{
int st=0,dr=14,mij;
while(st<dr-1){
mij=(st+dr)/2;
int i;
for(i=0;i<n;i++)
b[i]=w/n-1;
b[p1]=mij*(w/n);
b[p2]=mij*(w/n);
playRound(b,r);
int ok1=0,ok2=0;
if (r[p1]>b[p1])
ok1=1;
if (r[p2]>b[p2])
ok2=1;
if (ok1==ok2){
if (ok1==1)
st=mij;
else
dr=mij;
}
else
return ok2;
}
return 0;
}
int gw,gn;
bool cmp(int a,int b)
{
if (a==b)
return 0;
p1=a;
p2=b;
return greaterValue(100,gw);
}
int ans[105];
void find(int st,int dr,vector<int>aux)
{
if (st+1==dr){
ans[aux[0]]=st;
return ;
}
int l=0,r2=min(50,gw/(dr-st)+1),mij;
while(l<r2-1){
mij=(l+r2)/2;
int i;
for(i=0;i<gn;i++)
b[i]=0;
for(auto it:aux)
b[it]=mij;
playRound(b,r);
bool ok1=0,ok2=0;
for(auto it:aux){
if (r[it]<=b[it])
ok1=1;
else
ok2=1;
}
if (ok1 && ok2){
vector<int>aux1,aux2;
for(auto it:aux)
if (r[it]<=b[it])
aux1.push_back(it);
else
aux2.push_back(it);
find(st,st+aux1.size(),aux1);
find(st+aux1.size(),dr,aux2);
return ;
}
if (ok1)
r2=mij;
else
l=st;
}
}
void allValues(int n,int w,int *p)
{
gw=w;
gn=n;
vector<int>aux;
int i;
for(i=0;i<n;i++)
aux.push_back(i);
find(1,n+1,aux);
for(i=0;i<n;i++)
p[i]=ans[i];
return ;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
364 KB |
Output is correct |
2 |
Correct |
6 ms |
364 KB |
Output is correct |
3 |
Correct |
6 ms |
364 KB |
Output is correct |
4 |
Correct |
6 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
364 KB |
Output is correct |
2 |
Correct |
18 ms |
364 KB |
Output is correct |
3 |
Correct |
18 ms |
364 KB |
Output is correct |
4 |
Correct |
18 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
72 ms |
364 KB |
Output is correct |
2 |
Correct |
69 ms |
364 KB |
Output is correct |
3 |
Correct |
59 ms |
364 KB |
Output is correct |
4 |
Correct |
61 ms |
492 KB |
Output is correct |
5 |
Correct |
70 ms |
364 KB |
Output is correct |
6 |
Correct |
62 ms |
492 KB |
Output is correct |
7 |
Correct |
62 ms |
364 KB |
Output is correct |
8 |
Correct |
62 ms |
364 KB |
Output is correct |
9 |
Correct |
62 ms |
364 KB |
Output is correct |
10 |
Correct |
63 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
58 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |