結果
| 問題 |
No.205 マージして辞書順最小
|
| コンテスト | |
| ユーザー |
machy
|
| 提出日時 | 2015-06-17 22:23:49 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 16 ms / 5,000 ms |
| コード長 | 818 bytes |
| コンパイル時間 | 848 ms |
| コンパイル使用メモリ | 83,436 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-07 03:34:56 |
| 合計ジャッジ時間 | 1,744 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 15 |
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
using namespace std;
typedef long long LL;
const LL MOD=1000000000;
struct Comp{
bool operator()(const string& s1, const string& s2){
int i = 0;
for(; i < s1.size() && i < s2.size(); i++){
if(s1[i] < s2[i]) return true;
else if(s1[i] > s2[i]) return false;
}
return s1.size() > s2.size();
}
};
int main(){
LL N;
cin >> N;
vector<string> s(N);
string ans;
for(int i = 0; i < N; i++){
cin >> s[i];
}
while(true){
sort(s.begin(), s.end(), Comp());
if(s[0].empty()) break;
ans += s[0][0];
s[0] = s[0].substr(1);
}
cout << ans << endl;
return 0;
}
machy