Submission #128028

# Submission time Handle Problem Language Result Execution time Memory
128028 2019-07-10T10:38:27 Z MoNsTeR_CuBe Scales (IOI15_scales) C++17
38.4615 / 100
2 ms 504 KB
#include "scales.h"
#include <bits/stdc++.h>

using namespace std;



void init(int T) {
}

void orderCoins() {
    int W[] = {1, 2, 3, 4, 5, 6};
    
    vector< int > left;
    vector< int > right;
    
    left.push_back(getLightest(W[0], W[1], W[2]));
    left.push_back(getMedian(W[0], W[1], W[2]));
    for(int i = 0; i < 3; i++){
		bool verif = false;
		for(int j = 0; j < 2; j++){
			if(left[j] == W[i]) verif = true;
		}
		if(!verif) left.push_back(W[i]);
	}
	
	right.push_back(getLightest(W[3], W[4], W[5]));
	right.push_back(getMedian(W[3], W[4], W[5]));
	
	for(int i = 3; i < 6; i++){
		bool verif = false;
		for(int j = 0; j < 2; j++){
			if(right[j] == W[i]) verif = true;
		}
		if(!verif) right.push_back(W[i]);
	}
    
    int rem = 6;
    
    vector< int > ans;
    
    while(rem > 3){
		if((int)left.size() >= 2){
			ans.push_back(getHeaviest(left.back(), left[left.size()-2], right.back()));
			if(ans.back() == right.back()) right.pop_back();
			if(ans.back() == left.back()) left.pop_back();
		}else{
			ans.push_back(getHeaviest(left.back(), right[right.size()-2], right.back()));
			if(ans.back() == right.back()) right.pop_back();
			if(ans.back() == left.back()) left.pop_back();
		}
		rem--;
	}
    
    vector< int > remaining;
    
    while(!left.empty()){
		remaining.push_back(left.back());
		left.pop_back();
	}
    while(!right.empty()){
		remaining.push_back(right.back());
		right.pop_back();
	}
	ans.push_back(getHeaviest(remaining[0], remaining[1], remaining[2]));
	ans.push_back(getMedian(remaining[0], remaining[1], remaining[2]));
	ans.push_back(getLightest(remaining[0], remaining[1], remaining[2]));
	
	reverse(ans.begin(), ans.end());
	
    for(int i = 0; i < 6; i++){
		W[i] = ans[i];
	}
    answer(W);
}

Compilation message

scales.cpp: In function 'void init(int)':
scales.cpp:8:15: warning: unused parameter 'T' [-Wunused-parameter]
 void init(int T) {
               ^
# Verdict Execution time Memory Grader output
1 Partially correct 2 ms 376 KB Output is partially correct
2 Partially correct 2 ms 376 KB Output is partially correct
3 Partially correct 2 ms 256 KB Output is partially correct
4 Partially correct 2 ms 376 KB Output is partially correct
5 Partially correct 2 ms 376 KB Output is partially correct
6 Partially correct 2 ms 376 KB Output is partially correct
7 Partially correct 2 ms 376 KB Output is partially correct
8 Partially correct 2 ms 376 KB Output is partially correct
9 Partially correct 2 ms 376 KB Output is partially correct
10 Partially correct 2 ms 376 KB Output is partially correct
11 Partially correct 2 ms 376 KB Output is partially correct
12 Partially correct 2 ms 376 KB Output is partially correct
13 Partially correct 2 ms 376 KB Output is partially correct
14 Partially correct 2 ms 376 KB Output is partially correct
15 Partially correct 2 ms 376 KB Output is partially correct
16 Partially correct 2 ms 256 KB Output is partially correct
17 Partially correct 2 ms 376 KB Output is partially correct
18 Partially correct 2 ms 248 KB Output is partially correct
19 Partially correct 2 ms 504 KB Output is partially correct
20 Partially correct 2 ms 256 KB Output is partially correct
21 Partially correct 2 ms 376 KB Output is partially correct
22 Partially correct 2 ms 376 KB Output is partially correct
23 Partially correct 2 ms 256 KB Output is partially correct
24 Partially correct 2 ms 376 KB Output is partially correct
25 Partially correct 2 ms 256 KB Output is partially correct
26 Partially correct 2 ms 376 KB Output is partially correct
27 Partially correct 2 ms 376 KB Output is partially correct
28 Partially correct 2 ms 256 KB Output is partially correct
29 Partially correct 2 ms 380 KB Output is partially correct
30 Partially correct 2 ms 380 KB Output is partially correct
31 Partially correct 2 ms 376 KB Output is partially correct
32 Partially correct 2 ms 256 KB Output is partially correct
33 Partially correct 2 ms 376 KB Output is partially correct
34 Partially correct 2 ms 376 KB Output is partially correct
35 Partially correct 2 ms 256 KB Output is partially correct
36 Partially correct 2 ms 256 KB Output is partially correct
37 Partially correct 2 ms 376 KB Output is partially correct
38 Partially correct 2 ms 380 KB Output is partially correct
39 Partially correct 2 ms 376 KB Output is partially correct
40 Partially correct 2 ms 376 KB Output is partially correct