結果

問題 No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
ユーザー Kmcode1Kmcode1
提出日時 2016-10-14 22:41:52
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,388 bytes
コンパイル時間 2,335 ms
コンパイル使用メモリ 200,280 KB
実行使用メモリ 36,284 KB
最終ジャッジ日時 2024-05-01 23:34:12
合計ジャッジ時間 7,143 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 5 ms
5,376 KB
testcase_44 AC 6 ms
5,376 KB
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#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++){
			//q.push(make_pair(-sel[v[i].first], make_pair(v[i].second, v[i].first)));
			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;
}
0