| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 237412 | Leonardo_Paes | Devil's Share (RMI19_devil) | C++17 | 129 ms | 5972 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
int freq[15];
struct comp{
bool operator () (const string &a, const string &b){
if(a.size() == b.size()) return a < b;
return a.size() > b.size();
}
};
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int t;
cin >> t;
while(t--){
int k, n = 0;
cin >> k;
for(int i=1; i<=9; i++) cin >> freq[i], n += freq[i];
deque<string> s;
string rest;
int aux = n;
for(int i=1; i<=9; i++){
for(int j=1; j<=freq[i]; j++){
if(aux>=k)s.push_back(string(1, i + '0'));
else rest += i + '0';
aux--;
}
}
deque<string> fila;
int pos;
for(int i = n - k; i>=0; i--){
pos = i;
fila.push_back(s[i]);
if(i == 0 or s[i] != s[i-1]) break;
}
swap(fila, s);
int idpos = s.size() - 1;
while(fila.size() > pos) fila.pop_back();
while(!fila.empty()){
string u = fila.front();
fila.pop_front();
s[idpos] += u;
if((fila.empty() or u != fila.front()) and idpos){
while(idpos < (int)s.size()){
fila.push_back(s.back());
s.pop_back();
}
}
if(!idpos) idpos = s.size();
idpos--;
}
string ans;
for(auto q : s) ans += q;
cout << ans + rest << "\n";
}
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... | ||||
