# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
154152 | popovicirobert | Scales (IOI15_scales) | C++14 | 3 ms | 420 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() {
vector <int> a, b;
int z = getHeaviest(1, 2, 3), x = getLightest(1, 2, 3);
int y = 6 - x - z;
a = {x, y, z};
z = getHeaviest(4, 5, 6), x = getLightest(4, 5, 6);
y = 15 - x - z;
b = {x, y, z};
int sol[6];
int pa = 0, pb = 0;
for(int i = 0; i < 4; i++) {
vector <int> cur;
int j = 0;
while(cur.size() < 3) {
if(pa + j < 3) {
cur.push_back(a[pa + j]);
}
if(pb + j < 3 && cur.size() < 3) {
cur.push_back(b[pb + j]);
}
j++;
}
if(cur == a) {
sol[i] = a[pa++];
continue;
}
if(cur == b) {
sol[i] = b[pb++];
continue;
}
sol[i] = getLightest(cur[0], cur[1], cur[2]);
if(pa < 3 && a[pa] == sol[i]) {
pa++;
}
else {
pb++;
}
}
vector <int> cur;
int sum = 0;
for(int i = pa; i < 3; i++) {
cur.push_back(a[i]);
sum += a[i];
}
for(int i = pb; i < 3; i++) {
cur.push_back(b[i]);
sum += b[i];
}
if(pa == 1) {
sol[4] = a[1], sol[5] = a[2];
}
else if(pb == 1) {
sol[4] = b[1], sol[5] = b[2];
}
else {
cur.push_back(sol[0]);
sol[5] = getHeaviest(cur[0], cur[1], cur[2]);
sol[4] = sum - sol[5];
}
answer(sol);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |