# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
936685 | PagodePaiva | Scales (IOI15_scales) | C++17 | 1 ms | 600 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>
#include "scales.h"
using namespace std;
void init(int T) {
// cout << T << endl;
return;
}
void triple(vector <int> &v){
// cout << v[0] << ' ' << v[1] << ' ' << v[2] << endl;
int a = getHeaviest(v[0], v[1], v[2]);
// cout << a << endl;
int b = getMedian(v[0], v[1], v[2]);
int c;
for(auto x : v){
if(x == a) continue;
if(x == b) continue;
c = x;
break;
}
v = {a, b, c};
return;
}
void orderCoins() {
vector <int> v1 = {1, 2, 3};
vector <int> v2 = {4, 5, 6};
triple(v1);
// for(auto x : v1){
// cout << x << ' ';
// }
// cout << endl;
triple(v2);
// for(auto x : v2){
// cout << x << ' ';
// }
// cout << endl;
int x = getLightest(v1[2], v2[2], v1[1]);
// cout << x << ' ';
// cout << v1[2] << ' ' << v2[2] << endl;
vector <int> res;
if(x == v1[2]){
res.push_back(x);
v1.pop_back();
}
else{
res.push_back(x);
v2.pop_back();
}
// cout << res.back() << ' ';
while(!v1.empty() and !v2.empty()){
x = getMedian(res.back(), v1.back(), v2.back());
if(x == v1.back()) v1.pop_back();
else v2.pop_back();
res.push_back(x);
}
while(!v1.empty()){
res.push_back(v1.back());
v1.pop_back();
}
while(!v2.empty()){
res.push_back(v2.back());
v2.pop_back();
}
int w[6];
int i = 0;
for(auto x : res){
w[i] = x;
i++;
}
// for(int i = 0;i < 6;i++){
// cout << w[i] << ' ';
// }
answer(w);
return;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |