Submission #419125

#TimeUsernameProblemLanguageResultExecution timeMemory
419125LouayFarahScales (IOI15_scales)C++14
45.45 / 100
1 ms204 KiB
#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 timeMemoryGrader output
Fetching results...