結果

問題 No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
ユーザー face4face4
提出日時 2018-09-14 12:56:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 169 ms / 4,000 ms
コード長 849 bytes
コンパイル時間 916 ms
コンパイル使用メモリ 87,448 KB
実行使用メモリ 10,932 KB
最終ジャッジ日時 2023-09-18 07:37:15
合計ジャッジ時間 8,846 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 155 ms
10,728 KB
testcase_01 AC 135 ms
10,768 KB
testcase_02 AC 96 ms
10,632 KB
testcase_03 AC 131 ms
10,668 KB
testcase_04 AC 131 ms
10,568 KB
testcase_05 AC 115 ms
10,808 KB
testcase_06 AC 169 ms
10,824 KB
testcase_07 AC 102 ms
10,688 KB
testcase_08 AC 96 ms
10,560 KB
testcase_09 AC 110 ms
10,608 KB
testcase_10 AC 113 ms
10,372 KB
testcase_11 AC 131 ms
10,028 KB
testcase_12 AC 124 ms
10,440 KB
testcase_13 AC 86 ms
10,540 KB
testcase_14 AC 103 ms
10,476 KB
testcase_15 AC 75 ms
9,980 KB
testcase_16 AC 141 ms
10,216 KB
testcase_17 AC 140 ms
10,660 KB
testcase_18 AC 144 ms
10,708 KB
testcase_19 AC 84 ms
10,636 KB
testcase_20 AC 98 ms
10,588 KB
testcase_21 AC 91 ms
10,384 KB
testcase_22 AC 127 ms
10,464 KB
testcase_23 AC 107 ms
10,464 KB
testcase_24 AC 84 ms
10,368 KB
testcase_25 AC 120 ms
10,308 KB
testcase_26 AC 93 ms
10,180 KB
testcase_27 AC 118 ms
9,972 KB
testcase_28 AC 83 ms
10,532 KB
testcase_29 AC 127 ms
10,324 KB
testcase_30 AC 4 ms
5,672 KB
testcase_31 AC 2 ms
5,724 KB
testcase_32 AC 144 ms
10,932 KB
testcase_33 AC 148 ms
10,320 KB
testcase_34 AC 99 ms
10,628 KB
testcase_35 AC 3 ms
5,604 KB
testcase_36 AC 3 ms
5,732 KB
testcase_37 AC 3 ms
5,776 KB
testcase_38 AC 3 ms
5,672 KB
testcase_39 AC 4 ms
5,756 KB
testcase_40 AC 4 ms
5,696 KB
testcase_41 AC 11 ms
6,168 KB
testcase_42 AC 11 ms
6,048 KB
testcase_43 AC 12 ms
5,976 KB
testcase_44 AC 11 ms
6,224 KB
testcase_45 AC 5 ms
5,768 KB
testcase_46 AC 27 ms
6,156 KB
testcase_47 AC 26 ms
6,108 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<queue>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
    int n, k;
    cin >> n >> k;

    int s[n], p[n], u[n];
    for(int i = 0; i < n; i++)  cin >> s[i] >> p[i] >> u[i];

    vector<pair<pair<int,int>,int>> univ[100010];
    for(int i = 0; i < n; i++){
        univ[u[i]].push_back({{s[i],-p[i]},i});
    }

    priority_queue< pair< pair<int,pair<int,int>>, int> > pq;

    for(int u = 0; u <= 100000; u++){
        if(univ[u].size()){
            sort(univ[u].rbegin(), univ[u].rend());
            for(int i = 0; i < univ[u].size(); i++){
                int x = univ[u][i].second;
                pq.push({{s[x], {-i, -p[x]}},x});
            }
        }
    }

    for(int i = 0; i < k; i++){
        auto p = pq.top();  pq.pop();
        cout << p.second << endl;
    }

    return 0;
}
0