結果

問題 No.2740 Old Maid
ユーザー t98slidert98slider
提出日時 2024-04-20 13:35:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 852 bytes
コンパイル時間 4,384 ms
コンパイル使用メモリ 257,900 KB
実行使用メモリ 9,088 KB
最終ジャッジ日時 2024-04-20 13:35:39
合計ジャッジ時間 9,851 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
8,960 KB
testcase_01 AC 86 ms
9,088 KB
testcase_02 AC 87 ms
9,088 KB
testcase_03 AC 89 ms
8,960 KB
testcase_04 AC 87 ms
8,960 KB
testcase_05 AC 86 ms
8,960 KB
testcase_06 AC 90 ms
8,960 KB
testcase_07 AC 85 ms
9,088 KB
testcase_08 AC 85 ms
9,088 KB
testcase_09 AC 87 ms
8,960 KB
testcase_10 AC 86 ms
9,088 KB
testcase_11 AC 87 ms
8,960 KB
testcase_12 AC 61 ms
8,448 KB
testcase_13 AC 68 ms
8,704 KB
testcase_14 AC 14 ms
5,376 KB
testcase_15 AC 18 ms
5,376 KB
testcase_16 AC 47 ms
6,272 KB
testcase_17 AC 13 ms
5,376 KB
testcase_18 AC 68 ms
8,448 KB
testcase_19 AC 26 ms
5,376 KB
testcase_20 AC 76 ms
8,704 KB
testcase_21 AC 17 ms
5,376 KB
testcase_22 AC 45 ms
6,144 KB
testcase_23 AC 10 ms
5,376 KB
testcase_24 AC 24 ms
5,376 KB
testcase_25 AC 81 ms
8,832 KB
testcase_26 AC 3 ms
5,376 KB
testcase_27 AC 8 ms
5,376 KB
testcase_28 AC 47 ms
6,272 KB
testcase_29 AC 43 ms
6,144 KB
testcase_30 AC 4 ms
5,376 KB
testcase_31 AC 93 ms
8,960 KB
testcase_32 AC 29 ms
6,016 KB
testcase_33 AC 86 ms
8,832 KB
testcase_34 AC 43 ms
6,016 KB
testcase_35 AC 24 ms
5,376 KB
testcase_36 AC 27 ms
5,376 KB
testcase_37 AC 37 ms
5,888 KB
testcase_38 AC 23 ms
5,376 KB
testcase_39 AC 13 ms
5,376 KB
testcase_40 AC 54 ms
6,400 KB
testcase_41 AC 77 ms
8,576 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 2 ms
5,376 KB
testcase_44 AC 2 ms
5,376 KB
testcase_45 AC 2 ms
5,376 KB
testcase_46 AC 2 ms
5,376 KB
testcase_47 AC 2 ms
5,376 KB
testcase_48 AC 1 ms
5,376 KB
testcase_49 AC 2 ms
5,376 KB
testcase_50 AC 2 ms
5,376 KB
testcase_51 AC 2 ms
5,376 KB
testcase_52 AC 2 ms
5,376 KB
testcase_53 AC 2 ms
5,376 KB
testcase_54 AC 2 ms
5,376 KB
testcase_55 AC 1 ms
5,376 KB
testcase_56 AC 2 ms
5,376 KB
testcase_57 AC 2 ms
5,376 KB
testcase_58 AC 2 ms
5,376 KB
testcase_59 AC 2 ms
5,376 KB
testcase_60 AC 2 ms
5,376 KB
testcase_61 AC 2 ms
5,376 KB
testcase_62 AC 2 ms
5,376 KB
testcase_63 AC 2 ms
5,376 KB
testcase_64 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using S = pair<int,int>;
S op(S lhs, S rhs){
    return min(lhs, rhs);
}
S e(){
    return make_pair(1 << 30, -1);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, j = 0;
    cin >> n;
    vector<S> p(n);
    for(int i = 0; i < n; i++){
        cin >> p[i].first;
        p[i].second = i;
    }
    atcoder::segtree<S, op, e> seg(p);
    for(int i = 0; i < n; i += 2){
        int p1 = seg.all_prod().second;
        int p2 = seg.max_right(p1 + 1, [&](S v){return v == e();});
        if(p2 == n){
            p1 = seg.prod(0, p1).second;
            p2 = seg.max_right(p1 + 1, [&](S v){return v == e();});
        }
        cout << p[p1].first << ' ' << p[p2].first << (i + 2 == n ? '\n' : ' ');
        seg.set(p1, e());
        seg.set(p2, e());
    }
}
0