# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
551807 | Theo830 | Scales (IOI15_scales) | C++17 | 0 ms | 0 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>
using namespace std;
typedef long long ll;
const ll INF = 1e9+7;
const ll MOD = 998244353;
typedef pair<ll,ll> ii;
#define iii pair<ll,ii>
#define f(i,a,b) for(ll i = a;i < b;i++)
#define pb push_back
#define vll vector<ll>
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst)
///Stay Calm
///Look for special cases
///Beware of overflow and array bounds
///Think the problem backwards
///Training
void init(int T) {
}
void orderCoins() {
int W[] = {1, 2, 3, 4, 5, 6};
vector<int>ex[2];
ex[0].pb(getLightest(1,2,3));
ex[0].pb(getMedian(1,2,3));
set<ll>e;
f(i,0,3){
e.insert(i+1);
}
for(auto x:ex[0]){
e.erase(x);
}
ex[0].pb((*e.begin()));
ex[1].pb(getLightest(4,5,6));
ex[1].pb(getMedian(4,5,6));
set<ll>e;
f(i,3,6){
e.insert(i+1);
}
for(auto x:ex[1]){
e.erase(x);
}
ex[1].pb((*e.begin()));
f(i,0,6){
if(ex[0].empty()){
W[i] = ex[1][0];
ex[1].erase(ex[1].begin());
}
else if(ex[1].empty()){
W[i] = ex[0][0];
ex[0].erase(ex[0].begin());
}
else{
if((ll)(ex[0].size() + ex[1].size()) == 2){
W[i] = getMedian(ex[0][0],ex[1][0],W[i-1]);
}
else{
ll v;
if(ex[0].size() > 1){
v = ex[0][1];
}
else{
v = ex[1][1];
}
W[i] = getLightest(ex[0][0],ex[1][0],v);
}
if(W[i] == ex[0][0]){
ex[0].erase(ex[0].begin());
}
else{
ex[1].erase(ex[1].begin());
}
}
}
answer(W);
}