제출 #270618

#제출 시각아이디문제언어결과실행 시간메모리
270618eohomegrownappsDevil's Share (RMI19_devil)C++14
0 / 100
239 ms1404 KiB
#include <bits/stdc++.h> using namespace std; void processTest(){ int k; cin>>k; int n=0; vector<int> cnt(10,0); int ind = -1; for (int i = 1; i<=9; i++){ cin>>cnt[i]; n+=cnt[i]; if (cnt[i]>0){ind=i;} } if ((n%2==1&&(n+1)/2+1<=cnt[ind])||(n%2==0&&n/2<cnt[ind])){ for (int i = 1; i<=9; i++){ for (int j = 0; j<cnt[i]; j++){ cout<<i; } }cout<<'\n'; return; } //cout<<n<<'\n'; vector<int> ans(n,-1); ans[n-1]=ind; cnt[ind]--; for (int i = 0; i<cnt[ind]; i++){ ans[i*2]=ind; } cnt[ind]=0; int ptr = 0; for (int j = 1; j<=9; j++){ for (int k = 0; k<cnt[j]; k++){ while (ptr<n&&ans[ptr]!=-1){ptr++;} if (ptr==n){break;} ans[ptr]=j; } } for (int i : ans){ cout<<i; }cout<<'\n'; return; } int main(){ int t; cin>>t; for (int tc = 0; tc<t; tc++){ processTest(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...