結果

問題 No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
ユーザー beetbeet
提出日時 2018-12-03 16:29:10
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 189 ms / 4,000 ms
コード長 1,128 bytes
コンパイル時間 2,355 ms
コンパイル使用メモリ 215,416 KB
実行使用メモリ 14,640 KB
最終ジャッジ日時 2023-09-13 21:11:12
合計ジャッジ時間 10,731 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 170 ms
11,792 KB
testcase_01 AC 152 ms
11,820 KB
testcase_02 AC 108 ms
11,668 KB
testcase_03 AC 143 ms
11,732 KB
testcase_04 AC 143 ms
11,468 KB
testcase_05 AC 128 ms
11,804 KB
testcase_06 AC 189 ms
14,640 KB
testcase_07 AC 119 ms
11,796 KB
testcase_08 AC 111 ms
13,716 KB
testcase_09 AC 120 ms
12,968 KB
testcase_10 AC 121 ms
12,864 KB
testcase_11 AC 136 ms
12,264 KB
testcase_12 AC 128 ms
11,316 KB
testcase_13 AC 88 ms
12,948 KB
testcase_14 AC 105 ms
11,412 KB
testcase_15 AC 76 ms
12,936 KB
testcase_16 AC 149 ms
12,344 KB
testcase_17 AC 144 ms
12,864 KB
testcase_18 AC 150 ms
12,936 KB
testcase_19 AC 88 ms
12,964 KB
testcase_20 AC 99 ms
11,540 KB
testcase_21 AC 96 ms
12,756 KB
testcase_22 AC 131 ms
12,424 KB
testcase_23 AC 112 ms
12,744 KB
testcase_24 AC 89 ms
12,504 KB
testcase_25 AC 125 ms
12,356 KB
testcase_26 AC 97 ms
13,012 KB
testcase_27 AC 122 ms
12,360 KB
testcase_28 AC 87 ms
12,860 KB
testcase_29 AC 136 ms
12,568 KB
testcase_30 AC 11 ms
7,584 KB
testcase_31 AC 11 ms
7,504 KB
testcase_32 AC 145 ms
11,324 KB
testcase_33 AC 161 ms
12,484 KB
testcase_34 AC 111 ms
13,220 KB
testcase_35 AC 10 ms
7,536 KB
testcase_36 AC 11 ms
7,456 KB
testcase_37 AC 11 ms
7,516 KB
testcase_38 AC 11 ms
7,532 KB
testcase_39 AC 12 ms
7,376 KB
testcase_40 AC 13 ms
7,544 KB
testcase_41 AC 19 ms
7,892 KB
testcase_42 AC 19 ms
8,340 KB
testcase_43 AC 18 ms
8,084 KB
testcase_44 AC 19 ms
8,272 KB
testcase_45 AC 13 ms
7,596 KB
testcase_46 AC 34 ms
7,824 KB
testcase_47 AC 32 ms
8,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,k;
  cin>>n>>k;
  vector<Int> s(n),p(n),u(n);
  for(Int i=0;i<n;i++) cin>>s[i]>>p[i]>>u[i];

  vector<vector<Int> > G(11);
  for(Int i=0;i<n;i++) G[s[i]].emplace_back(i);

  const Int MAX = 114514;
  vector<Int> cnt(MAX,0);
  for(Int x=10;x>=0;x--){
    using T = tuple<Int, Int, Int>;
    using PQ = priority_queue<T, vector<T>, greater<T> >;
    vector<PQ> pqs(MAX);
    PQ all;
    for(Int i:G[x])
      pqs[u[i]].emplace(cnt[u[i]],p[i],i);
    
    for(PQ &pq: pqs){
      if(pq.empty()) continue;
      all.emplace(pq.top());
      pq.pop();
    }
    while(k&&!all.empty()){
      k--;
      Int i;
      tie(ignore,ignore,i)=all.top();all.pop();
      cout<<i<<endl;
      cnt[u[i]]++;
      auto &pq=pqs[u[i]];
      if(pq.empty()) continue;
      tie(ignore,ignore,i)=pq.top();pq.pop();
      all.emplace(cnt[u[i]],p[i],i);
    }
  }
  
  return 0;
}
0