# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
49790 | zetapi | Scales (IOI15_scales) | C++14 | 4 ms | 1196 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 "scales.h"
#include "bits/stdc++.h"
using namespace std;
#define mp make_pair
#define pb push_back
void init(int T)
{
/* ... */
}
void erase(int X,vector<int> &f,vector<int> &s)
{
for(int A=0;A<f.size();A++)
if(f[A]==X)
{
f.erase(f.begin()+A);
return ;
}
for(int A=0;A<s.size();A++)
if(s[A]==X)
{
s.erase(s.begin()+A);
return ;
}
return ;
}
void orderCoins()
{
/* ... */
int W[] = {1, 2, 3, 4, 5, 6};
vector<int> f(3),s(3),res;
f={getLightest(1,2,3),getMedian(1,2,3),6-(f[0]+f[1])};
s={getLightest(4,5,6),getMedian(4,5,6),15-(s[0]+s[1])};
while((!f.empty())||(!s.empty()))
{
if(f.empty())
{
while(!s.empty())
{
res.pb(*s.begin());
s.erase(s.begin());
}
}
else if(s.empty())
{
while(!f.empty())
{
res.pb(*f.begin());
f.erase(f.begin());
}
}
else if(f.size()==1 && s.size()==1)
{
res.pb(getMedian(res[0],f[0],s[0]));
res.pb(f[0]+s[0]-res.back());
erase(res[res.size()-2],f,s);
erase(res[res.size()-1],f,s);
}
else
{
if(res.empty())
{
res.pb(getLightest(f[0],f[1],s[0]));
erase(res.back(),f,s);
}
else
{
res.pb(getMedian(res[0],f[0],s[0]));
erase(res.back(),f,s);
}
}
}
for(int A=0;A<6;A++)
W[A]=res[A];
answer(W);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |