結果

問題 No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
ユーザー kyuridenamidakyuridenamida
提出日時 2016-10-28 19:32:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 347 ms / 4,000 ms
コード長 1,669 bytes
コンパイル時間 1,095 ms
コンパイル使用メモリ 107,248 KB
実行使用メモリ 19,840 KB
最終ジャッジ日時 2024-05-03 07:24:14
合計ジャッジ時間 8,087 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 319 ms
19,448 KB
testcase_01 AC 261 ms
19,840 KB
testcase_02 AC 173 ms
16,256 KB
testcase_03 AC 233 ms
12,544 KB
testcase_04 AC 232 ms
11,688 KB
testcase_05 AC 228 ms
17,152 KB
testcase_06 AC 347 ms
18,652 KB
testcase_07 AC 223 ms
19,712 KB
testcase_08 AC 175 ms
14,960 KB
testcase_09 AC 150 ms
6,912 KB
testcase_10 AC 112 ms
5,376 KB
testcase_11 AC 126 ms
5,376 KB
testcase_12 AC 124 ms
5,376 KB
testcase_13 AC 77 ms
5,376 KB
testcase_14 AC 98 ms
5,376 KB
testcase_15 AC 63 ms
5,376 KB
testcase_16 AC 127 ms
5,376 KB
testcase_17 AC 140 ms
5,376 KB
testcase_18 AC 138 ms
5,376 KB
testcase_19 AC 78 ms
5,376 KB
testcase_20 AC 94 ms
5,376 KB
testcase_21 AC 89 ms
5,376 KB
testcase_22 AC 127 ms
5,376 KB
testcase_23 AC 109 ms
5,376 KB
testcase_24 AC 82 ms
5,376 KB
testcase_25 AC 118 ms
5,376 KB
testcase_26 AC 83 ms
5,376 KB
testcase_27 AC 113 ms
5,376 KB
testcase_28 AC 78 ms
5,376 KB
testcase_29 AC 113 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 167 ms
5,496 KB
testcase_33 AC 183 ms
5,376 KB
testcase_34 AC 146 ms
8,832 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 2 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 2 ms
5,376 KB
testcase_39 AC 4 ms
5,376 KB
testcase_40 AC 4 ms
5,376 KB
testcase_41 AC 11 ms
5,376 KB
testcase_42 AC 10 ms
5,376 KB
testcase_43 AC 10 ms
5,376 KB
testcase_44 AC 9 ms
5,376 KB
testcase_45 AC 4 ms
5,376 KB
testcase_46 AC 31 ms
5,376 KB
testcase_47 AC 29 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <queue>
#include <cstdio>
#include <sstream>
#include <set>
#include <cassert>
#include <map>
#include <array>
using namespace std;
typedef unsigned __int128 Hash;



map<int, priority_queue<pair<int,int>>  > g[11];
int N,K;
vector<int> res;

map<int,int> picked_counter; // [univ] = #
priority_queue< array<int,3> > Q;

int get_best_univ(map<int,priority_queue< pair<int,int> > > &score){

	while(Q.size()){
		auto q = Q.top();

		int id = q[2];

		bool bad = false;
		if( score[id].size() == 0 ){
			Q.pop();
			continue;
		}
		if( score[id].top().first != q[1] ) bad = true;
		if( picked_counter[id] != q[0] ) bad = true;

		if( bad ){
			Q.pop();
			//Q.push({picked_counter[id],score[id].top().first,id});
		}else{
			return id;
		}
	}
	return -1;
}
void pick(int id,map<int,priority_queue< pair<int,int> > > &score){
	assert(score[id].size()>0);

	int me = score[id].top().second;
	picked_counter[id]--;
	score[id].pop();
	Q.push({picked_counter[id],score[id].top().first,id});
	res.push_back(me);
	K--;
}


void solve(map<int, priority_queue< pair<int,int> > > &score){
	Q = priority_queue< array<int,3> >();

	for( auto i : score ){
		Q.push({picked_counter[i.first],i.second.top().first,i.first});
	}
	while(K>0){
		int uid = get_best_univ(score);
		if( uid == -1 ) break;
		pick(uid,score);
	}

}
int main(){
	cin >> N >> K;

	set<int> univ;
	for(int i = 0 ; i < N ; i++){
		int S,P,U;
		cin >> S >> P >> U;
		g[S][U].push({-P,i});
		univ.insert(U);
	}

	for(int i = 10 ; i >= 0 ; i--){
		solve(g[i]);
	}
	for(int i = 0 ; i < res.size() ; i++)
		cout << res[i] << endl;

}
0