# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
477323 | Alexandruabcde | Devil's Share (RMI19_devil) | C++14 | 85 ms | 7120 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef pair <string, int> PSI;
int fr[10];
void do_Testcase () {
int K;
cin >> K;
for (int i = 1; i <= 9; ++ i )
cin >> fr[i];
string S;
int cif = 9;
for (int i = 1; i <= K-1; ++ i ) {
while (fr[cif] == 0) -- cif;
S += (cif + '0');
-- fr[cif];
}
reverse(S.begin(), S.end());
while (fr[cif] == 0) -- cif;
string pt_Max;
pt_Max.push_back('0' + cif);
PSI Max = {pt_Max, fr[cif]};
vector <PSI> v;
for (int i = 0; i < cif; ++ i ) {
if (fr[i] <= 0) continue;
string aux;
aux.push_back(i + '0');
v.push_back({aux, fr[i]});
}
for (int i = 0; i < v.size(); ++ i ) {
auto it = v[i];
while (it.second >= Max.second) {
Max.first += it.first;
it.second -= Max.second;
}
if (it.second > 0) {
v.push_back({Max.first + it.first, it.second});
Max.second -= it.second;
}
}
for (int i = 0; i < Max.second; ++ i )
cout << Max.first;
cout << S << '\n';
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int T = 1;
cin >> T;
for (; T; -- T )
do_Testcase();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |