Submission #270617

#TimeUsernameProblemLanguageResultExecution timeMemory
270617eohomegrownappsDevil's Share (RMI19_devil)C++14
0 / 100
245 ms2040 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<=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...