結果

問題 No.205 マージして辞書順最小
ユーザー 👑 nu50218nu50218
提出日時 2019-09-10 21:33:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 632 bytes
コンパイル時間 2,277 ms
コンパイル使用メモリ 180,768 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-15 13:13:58
合計ジャッジ時間 2,825 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
4,380 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 4 ms
4,380 KB
testcase_11 AC 3 ms
4,384 KB
testcase_12 WA -
testcase_13 AC 3 ms
4,384 KB
testcase_14 AC 2 ms
4,384 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,384 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    cin >> N;
    priority_queue<deque<char>, vector<deque<char>>, greater<deque<char>>> pque;
    for (size_t i = 0; i < N; i++) {
        string S;
        cin >> S;
        deque<char> deq;
        for (size_t j = 0; j < S.size(); j++) {
            deq.push_back(S[j]);
        }
        pque.push(deq);
    }
    string ans = "";
    while (pque.size()) {
        auto deq = pque.top();
        pque.pop();
        ans += deq.front();
        deq.pop_front();
        if (deq.size()) {
            pque.push(deq);
        }
    }
    cout << ans << endl;
}
0