# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
419125 | LouayFarah | Scales (IOI15_scales) | C++14 | 1 ms | 204 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 "bits/stdc++.h"
#include "scales.h"
using namespace std;
int t;
void init(int T)
{
t = T;
}
int getHeaviest(int a, int b, int c);
int getMedian(int a, int b, int c);
int getLightest(int a, int b, int c);
int getNextLightest(int a, int b, int c, int d);
void answer(int w[]);
void orderCoins()
{
int w[6];
int a[3], b[3];
a[0] = getLightest(1, 2, 3);
a[2] = getHeaviest(1, 2, 3);
b[0] = getLightest(4, 5, 6);
b[2] = getHeaviest(4, 5, 6);
a[1] = 6 - a[0] - a[2];
b[1] = 15 - b[0] - b[2];
int reste = 6;
int i = 0, j = 0;
int k = 0;
while(reste>=3&&i<3&&j<3)
{
if(i<2)
{
int x = getLightest(a[i], a[i+1], b[j]);
if(x==a[i])
{
w[k++] = a[i];
i++;
}
else
{
w[k++] = b[j];
j++;
}
}
else if(i==2)
{
int x = getLightest(a[i], b[j], b[j+1]);
if(x==a[i])
{
w[k++] = a[i];
i++;
}
else
{
w[k++] = b[j];
j++;
}
}
reste--;
}
if(i==3)
{
while(j<3)
{
w[k++] = b[j++];
}
}
else if(j==3)
{
while(i<3)
{
w[k++] = a[i++];
}
}
else
{
int x = getHeaviest(a[i], b[j], a[0]);
if(x==b[j])
{
w[4] = a[i];
w[5] = b[j];
}
else
{
w[4] = b[j];
w[5] = a[i];
}
}
answer(w);
return;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |