Submission #258189

# Submission time Handle Problem Language Result Execution time Memory
258189 2020-08-05T13:57:04 Z oolimry Devil's Share (RMI19_devil) C++14
0 / 100
360 ms 262148 KB
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using namespace std;
typedef pair<int,int> ii;

signed main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	
	int TC; cin >> TC;
	
	while(TC--){
		
		int K; cin >> K;
		int cnt[10];
		
		int S = 0;
		for(int i = 1;i <= 9;i++){
			cin >> cnt[i];
			S += cnt[i];
		}
		
		vector<int> lastK;
		
		int _K = K-1;
		int big = 9;
		while(_K--){
			while(cnt[big] == 0) big--;
			cnt[big]--;
			lastK.push_back(big);
		}
		
		S -= (K-1);
		
		vector<int> front;
		
		if(cnt[2] == 0){
			front.assign(S,1);
		}		
		else if(cnt[1] == 0){
			front.assign(S,2);
		}
		else if(cnt[1] >= cnt[2]){
			int grp = S / cnt[2];
			while(cnt[2]--){
				front.push_back(2);
				for(int i = 1;i < grp;i++){
					front.push_back(1);
					cnt[1]--;
				}
			}
			while(cnt[1]--) front.push_back(1);
		}
		else{
			int grp = S / cnt[1];
			if(S % cnt[1] != 0) grp++;
			for(int i = 0;i < S;i++){
				if(i % grp == 0) front.push_back(1);
				else front.push_back(2);
			}
			reverse(all(front));
		}
		
		for(int x : front) cout << x;
		
		reverse(all(lastK));
		for(int x : lastK) cout << x;
		cout << "\n";
	}
}


# Verdict Execution time Memory Grader output
1 Runtime error 310 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 360 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 75 ms 1272 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 310 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)