結果
問題 | No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい |
ユーザー |
![]() |
提出日時 | 2018-12-03 16:29:10 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 169 ms / 4,000 ms |
コード長 | 1,128 bytes |
コンパイル時間 | 2,006 ms |
コンパイル使用メモリ | 211,000 KB |
最終ジャッジ日時 | 2025-01-06 18:02:09 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 48 |
ソースコード
#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; }