# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
39898 | mohammad_kilani | Scales (IOI15_scales) | C++14 | 1 ms | 2024 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;
void init(int T) {
}
void orderCoins() {
int val[7];
vector< pair<int,int> > v;
for(int i=1;i<6;i+=3){
int a = getMedian(i,i+1,i+2);
int b = getHeaviest(i,i+1,i+2);
int c;
if(i != a && i != b) c = i;
if(i + 1 != a && i + 1 != b) c = i + 1;
if(i + 2 != a && i + 2 != b) c = i + 2;
v.push_back(make_pair(0,c));
v.push_back(make_pair(1,a));
v.push_back(make_pair(2,b));
}
sort(v.begin(),v.end());
int idx = 0;
int w[6];
while(v.size() > 3){
int a = v[0].second;
int b = v[1].second;
int c = v[2].second;
int ans1 = getLightest(a,b,c);
w[idx++] = ans1;
if(ans1 == a) v[0].first = 100;
else if(ans1 == b) v[1].first = 100;
else if(ans1 == c) v[2].first = 100;
sort(v.begin(),v.end());
v.pop_back();
}
int cur1 = getMedian(v[0].second,v[1].second,v[2].second);
int cur2 = getHeaviest(v[0].second,v[1].second,v[2].second);
int cur3;
if(v[0].second != cur1 && v[0].second != cur2) cur3 = v[0].second;
if(v[1].second != cur1 && v[1].second != cur2) cur3 = v[1].second;
if(v[2].second != cur1 && v[2].second != cur2) cur3 = v[2].second;
w[idx++] = cur3;
w[idx++] = cur1;
w[idx++] = cur2;
answer(w);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |