結果
| 問題 | No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい |
| コンテスト | |
| ユーザー |
Kmcode1
|
| 提出日時 | 2016-10-14 22:48:00 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 280 ms / 4,000 ms |
| コード長 | 1,313 bytes |
| 記録 | |
| コンパイル時間 | 2,724 ms |
| コンパイル使用メモリ | 200,320 KB |
| 実行使用メモリ | 36,544 KB |
| 最終ジャッジ日時 | 2024-11-22 08:12:35 |
| 合計ジャッジ時間 | 7,005 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 48 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:21:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
21 | scanf("%d%d%d", &s, &p, &u);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
int n, k;
map<int, vector<pair<int, int> > > mp; //u,p
map<int, vector<int> > IDS;
priority_queue<pair<int, pair<int,int> > > q; //selected, penalty university
map<int, int> sel;
vector<int> ans;
map<int, deque<pair<int, int> > > team; //university, pena,id
int main(){
cin >> n >> k;
for (int i = 0; i < n; i++){
int s, p, u;
scanf("%d%d%d", &s, &p, &u);
mp[-s].push_back(make_pair(u, p));
IDS[-s].push_back(i);
}
for (auto it = mp.begin(); it != mp.end(); it++){
vector<pair<int, int> > &v = (*it).second;
for (int i = 0; i < v.size(); i++){
team[v[i].first].push_back(make_pair(v[i].second, IDS[(*it).first][i]));
}
for (auto it = team.begin(); it != team.end(); it++){
sort((*it).second.begin(), (*it).second.end());
q.push(make_pair(-sel[(*it).first], make_pair(-(*it).second[0].first, (*it).first)));
}
while (k>0 && q.size()){
pair<int, pair<int, int> > b = q.top();
q.pop();
k--;
int uni = b.second.second;
sel[uni]++;
ans.push_back(team[uni].front().second);
team[uni].pop_front();
if (team[uni].size()){
q.push(make_pair(-sel[uni], make_pair(-team[uni].front().first, uni)) );
}
}
team.clear();
}
for (int i = 0; i < ans.size(); i++){
printf("%d\n", ans[i]);
}
return 0;
}
Kmcode1