# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
642509 | 2022-09-19T16:58:27 Z | Tenis0206 | Devil's Share (RMI19_devil) | C++11 | 455 ms | 5168 KB |
#include <bits/stdc++.h> using namespace std; int k; vector<string> v; queue<string> q; int fr[15]; int get_max() { for(int c=9; c>=1; c--) { if(fr[c]) { return c; } } } void solve_test() { cin>>k; for(int i=1; i<=9; i++) { cin>>fr[i]; } string rez; for(int i=1; i<k; i++) { rez.push_back(get_max() + '0'); --fr[get_max()]; } reverse(rez.begin(),rez.end()); int Max = get_max(); for(int i=1; i<=fr[Max]; i++) { string aux; aux.push_back(Max + '0'); v.push_back(aux); } for(int c=1; c<Max; c++) { for(int i=1; i<=fr[c]; i++) { string aux; aux.push_back(c + '0'); q.push(aux); } } int poz = v.size() - 1; while(!q.empty()) { string s = q.front(); q.pop(); v[poz] += s; --poz; if(poz < 0) { poz = v.size() - 1; } else if(q.empty() || s!=q.front()) { while(v.size()-1 > poz) { q.push(v.back()); v.pop_back(); } } } for(int i=v.size()-1; i>=0; i--) { rez = v[i] + rez; } v.clear(); cout<<rez<<'\n'; } int main() { ios::sync_with_stdio(false); cin.tie(0); int t; cin>>t; for(int test=1; test<=t; test++) { solve_test(); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 65 ms | 2012 KB | Output is correct |
2 | Correct | 72 ms | 1736 KB | Output is correct |
3 | Correct | 55 ms | 1692 KB | Output is correct |
4 | Correct | 69 ms | 2064 KB | Output is correct |
5 | Correct | 47 ms | 1372 KB | Output is correct |
6 | Correct | 46 ms | 1432 KB | Output is correct |
7 | Correct | 41 ms | 1268 KB | Output is correct |
8 | Correct | 37 ms | 1624 KB | Output is correct |
9 | Correct | 53 ms | 4552 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 44 ms | 1736 KB | Output is correct |
2 | Correct | 40 ms | 1456 KB | Output is correct |
3 | Correct | 455 ms | 4376 KB | Output is correct |
4 | Correct | 279 ms | 4556 KB | Output is correct |
5 | Correct | 71 ms | 4624 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 340 KB | Output is correct |
2 | Correct | 65 ms | 2012 KB | Output is correct |
3 | Correct | 72 ms | 1736 KB | Output is correct |
4 | Correct | 55 ms | 1692 KB | Output is correct |
5 | Correct | 69 ms | 2064 KB | Output is correct |
6 | Correct | 47 ms | 1372 KB | Output is correct |
7 | Correct | 46 ms | 1432 KB | Output is correct |
8 | Correct | 41 ms | 1268 KB | Output is correct |
9 | Correct | 37 ms | 1624 KB | Output is correct |
10 | Correct | 53 ms | 4552 KB | Output is correct |
11 | Correct | 44 ms | 1736 KB | Output is correct |
12 | Correct | 40 ms | 1456 KB | Output is correct |
13 | Correct | 455 ms | 4376 KB | Output is correct |
14 | Correct | 279 ms | 4556 KB | Output is correct |
15 | Correct | 71 ms | 4624 KB | Output is correct |
16 | Correct | 55 ms | 1964 KB | Output is correct |
17 | Correct | 58 ms | 2144 KB | Output is correct |
18 | Correct | 49 ms | 1816 KB | Output is correct |
19 | Correct | 86 ms | 2632 KB | Output is correct |
20 | Correct | 28 ms | 1364 KB | Output is correct |
21 | Correct | 27 ms | 1340 KB | Output is correct |
22 | Correct | 25 ms | 1744 KB | Output is correct |
23 | Correct | 35 ms | 5168 KB | Output is correct |