結果
| 問題 |
No.205 マージして辞書順最小
|
| コンテスト | |
| ユーザー |
koyopro
|
| 提出日時 | 2015-10-21 23:49:46 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 5,000 ms |
| コード長 | 723 bytes |
| コンパイル時間 | 1,534 ms |
| コンパイル使用メモリ | 165,728 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-22 11:24:30 |
| 合計ジャッジ時間 | 2,353 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 15 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(int i=0; i<(n); i++)
int N,T;
class Comp {
public:
bool operator()(string a, string b) {
REP(i,a.size()) {
if (a[i] == b[i]) continue;
if (i >= b.size()) return false;
return a[i] > b[i];
}
return true;
}
};
signed main()
{
cin >> N;
string S;
priority_queue<string, vector<string>, Comp> que;
REP(i,N) {
cin >> S;
que.push(S);
}
string t = "";
while(que.size()) {
string s = que.top();
que.pop();
t += s[0];
s.erase(s.begin());
if (s.size()) que.push(s);
}
cout << t << endl;
return 0;
}
koyopro