Submission #1219996

#TimeUsernameProblemLanguageResultExecution timeMemory
1219996Marco_EscandonScales (IOI15_scales)C++20
45.45 / 100
1 ms328 KiB
#include "scales.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define x first
#define y second
void init(int T) {
}
void orderCoins() 
{
    int W[6];
    deque<pair<ll,ll>> p1={{0,1},{0,2},{0,3}},p2={{0,4},{0,5},{0,6}};
    ll t1=getHeaviest(p1[0].y,p1[1].y,p1[2].y); p1[t1-1].x=20;
    t1=getMedian(p1[0].y,p1[1].y,p1[2].y); p1[t1-1].x=10;
    sort(p1.begin(),p1.end());

    t1=getHeaviest(p2[0].y,p2[1].y,p2[2].y); p2[t1-3-1].x=20;
    t1=getMedian(p2[0].y,p2[1].y,p2[2].y); p2[t1-3-1].x=10;
    sort(p2.begin(),p2.end());
    ll s=0;
    while(p1.size()!=0&&p2.size()!=0)
    {
        vector<ll> q;
        for(int i=0; i<min(2,(int)p1.size()); i++)
        {
            q.push_back(p1[i].y);
        }
        int asdf=q.size();
        for(int i=0; i<min(3-(int)asdf,(int)p2.size()); i++)
        {
            q.push_back(p2[i].y);
        }
        ll temp=getLightest(q[0],q[1],q[2]);
        if(temp==p1.front().y)
        {
            W[s]=p1.front().y;p1.pop_front();
            s++;
        }
        else
        {
            W[s]=p2.front().y;p2.pop_front();
            s++;
        }
        if(p1.size()+p2.size()==2)
        {
            if(p1.size()==0||p2.size()==0) break;
            temp=getMedian(q[0],q[1],q[2]);
            if(temp==p1.front().y)
            {
                W[s]=p1.front().y;p1.pop_front();
                s++;
            }
            else
            {
                W[s]=p2.front().y;p2.pop_front();
                s++;
            }
            break;
        }
    }
    while(p1.size()!=0)
    {
        W[s]=p1.front().y;p1.pop_front();
        s++;
    }
    while(p2.size()!=0)
    {
        W[s]=p2.front().y;p2.pop_front();
        s++;
    }
    answer(W);
}
#Verdict Execution timeMemoryGrader output
Fetching results...