結果

問題 No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
ユーザー parukiparuki
提出日時 2016-10-15 22:01:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 80 ms / 4,000 ms
コード長 1,412 bytes
コンパイル時間 2,246 ms
コンパイル使用メモリ 190,724 KB
実行使用メモリ 10,956 KB
最終ジャッジ日時 2024-05-02 02:18:41
合計ジャッジ時間 5,964 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
10,628 KB
testcase_01 AC 67 ms
10,796 KB
testcase_02 AC 47 ms
9,804 KB
testcase_03 AC 53 ms
9,344 KB
testcase_04 AC 52 ms
9,344 KB
testcase_05 AC 55 ms
10,196 KB
testcase_06 AC 80 ms
10,956 KB
testcase_07 AC 62 ms
10,776 KB
testcase_08 AC 54 ms
10,320 KB
testcase_09 AC 49 ms
9,344 KB
testcase_10 AC 43 ms
8,832 KB
testcase_11 AC 44 ms
8,448 KB
testcase_12 AC 45 ms
8,960 KB
testcase_13 AC 39 ms
8,960 KB
testcase_14 AC 41 ms
8,832 KB
testcase_15 AC 39 ms
8,412 KB
testcase_16 AC 45 ms
8,704 KB
testcase_17 AC 45 ms
9,064 KB
testcase_18 AC 48 ms
9,088 KB
testcase_19 AC 39 ms
8,832 KB
testcase_20 AC 42 ms
9,088 KB
testcase_21 AC 40 ms
8,832 KB
testcase_22 AC 43 ms
8,704 KB
testcase_23 AC 41 ms
8,960 KB
testcase_24 AC 38 ms
8,576 KB
testcase_25 AC 43 ms
8,704 KB
testcase_26 AC 41 ms
8,704 KB
testcase_27 AC 42 ms
8,432 KB
testcase_28 AC 39 ms
9,088 KB
testcase_29 AC 43 ms
8,832 KB
testcase_30 AC 4 ms
5,888 KB
testcase_31 AC 4 ms
6,016 KB
testcase_32 AC 49 ms
9,216 KB
testcase_33 AC 48 ms
8,704 KB
testcase_34 AC 48 ms
9,472 KB
testcase_35 AC 4 ms
6,016 KB
testcase_36 AC 3 ms
6,144 KB
testcase_37 AC 4 ms
6,016 KB
testcase_38 AC 4 ms
6,016 KB
testcase_39 AC 5 ms
6,144 KB
testcase_40 AC 4 ms
6,016 KB
testcase_41 AC 8 ms
6,400 KB
testcase_42 AC 8 ms
6,272 KB
testcase_43 AC 8 ms
6,384 KB
testcase_44 AC 8 ms
6,248 KB
testcase_45 AC 5 ms
6,144 KB
testcase_46 AC 10 ms
6,400 KB
testcase_47 AC 9 ms
6,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
#define mt make_tuple

// solved, -penalty, id
vector<tuple<int, int, int>> univ[100001];
int idx[100001];

int main(){
    int N, K;
    cin >> N >> K;
    vi S(N), P(N), U(N);
    rep(i, N) {
        scanf("%d%d%d", &S[i], &P[i], &U[i]);
        univ[U[i]].emplace_back(-S[i], +P[i], i);
    }

    // +solved, -others, -penalty, univ, id
    priority_queue<tuple<int, int, int, int, int> > Q;
    rep(i, 100001) {
        if(sz(univ[i])) {
            sort(all(univ[i]));
            int s, p, k;
            tie(s, p, k) = univ[i][0];
            Q.push(mt(-s, 0, -p, i, k));
            
        }
    }

    rep(i, K) {
        int s, cnt, p, uni, id;
        tie(s, cnt, p, uni, id) = Q.top();
        Q.pop();
        printf("%d\n", id);
        if(++idx[uni] < sz(univ[uni])) {
            tie(s, p, id) = univ[uni][idx[uni]];
            Q.push(mt(-s, cnt - 1, -p, uni, id));
        }
    }
}
0