This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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];
}
if(K == 2){
int last = 0;
int big = 9;
while(cnt[big] == 0) big--;
last = big;
cnt[big]--;
while(cnt[big] == 0) big--;
S--;
int l = 1, r = big;
bool left = false;
while(S--){
if(left){
while(cnt[l] == 0) l++;
cout << l;
cnt[l]--;
}
else{
while(cnt[r] == 0) r--;
cout << r;
cnt[r]--;
}
left = !left;
}
cout << last;
cout << '\n';
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |