답안 #258177

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
258177 2020-08-05T13:42:53 Z oolimry Devil's Share (RMI19_devil) C++14
0 / 100
87 ms 1884 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] == 1){
			front.assign(S,2);
		}
		else if(cnt[1] >= cnt[2]){
			int grp = S / cnt[2];
			for(int i = 1;i <= S;i++){
				if(i % grp == 0) front.push_back(2);
				else front.push_back(1);
			}
			reverse(all(front));
		}
		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";
	}
}


# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 8 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 8 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 87 ms 1884 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 8 (could be triggered by violating memory limits)