結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 415 ms
19,576 KB
testcase_01 AC 356 ms
19,840 KB
testcase_02 AC 256 ms
16,256 KB
testcase_03 AC 290 ms
12,544 KB
testcase_04 AC 278 ms
11,776 KB
testcase_05 AC 295 ms
17,152 KB
testcase_06 AC 452 ms
18,780 KB
testcase_07 AC 280 ms
19,712 KB
testcase_08 AC 242 ms
14,960 KB
testcase_09 AC 191 ms
6,928 KB
testcase_10 AC 805 ms
5,376 KB
testcase_11 AC 2,220 ms
5,464 KB
testcase_12 AC 448 ms
5,376 KB
testcase_13 AC 134 ms
5,376 KB
testcase_14 AC 642 ms
5,376 KB
testcase_15 AC 70 ms
5,376 KB
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
権限があれば一括ダウンロードができます

ソースコード

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