結果

問題 No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
ユーザー 👑 kmjpkmjp
提出日時 2016-10-14 22:32:38
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 60 ms / 4,000 ms
コード長 1,323 bytes
コンパイル時間 1,755 ms
コンパイル使用メモリ 159,528 KB
実行使用メモリ 10,608 KB
最終ジャッジ日時 2023-08-14 11:07:19
合計ジャッジ時間 5,904 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
10,080 KB
testcase_01 AC 49 ms
10,608 KB
testcase_02 AC 37 ms
9,496 KB
testcase_03 AC 43 ms
9,444 KB
testcase_04 AC 41 ms
9,228 KB
testcase_05 AC 42 ms
9,592 KB
testcase_06 AC 60 ms
10,480 KB
testcase_07 AC 44 ms
10,208 KB
testcase_08 AC 39 ms
9,696 KB
testcase_09 AC 35 ms
9,264 KB
testcase_10 AC 34 ms
8,868 KB
testcase_11 AC 36 ms
8,272 KB
testcase_12 AC 36 ms
8,596 KB
testcase_13 AC 33 ms
8,884 KB
testcase_14 AC 36 ms
8,612 KB
testcase_15 AC 32 ms
8,092 KB
testcase_16 AC 37 ms
8,508 KB
testcase_17 AC 38 ms
8,524 KB
testcase_18 AC 37 ms
8,980 KB
testcase_19 AC 33 ms
8,980 KB
testcase_20 AC 34 ms
8,736 KB
testcase_21 AC 31 ms
8,556 KB
testcase_22 AC 35 ms
8,484 KB
testcase_23 AC 33 ms
8,808 KB
testcase_24 AC 30 ms
8,424 KB
testcase_25 AC 35 ms
8,364 KB
testcase_26 AC 33 ms
8,556 KB
testcase_27 AC 35 ms
8,228 KB
testcase_28 AC 30 ms
8,828 KB
testcase_29 AC 37 ms
8,652 KB
testcase_30 AC 3 ms
5,884 KB
testcase_31 AC 3 ms
5,816 KB
testcase_32 AC 41 ms
9,180 KB
testcase_33 AC 40 ms
8,584 KB
testcase_34 AC 35 ms
9,320 KB
testcase_35 AC 3 ms
5,960 KB
testcase_36 AC 3 ms
5,884 KB
testcase_37 AC 3 ms
5,908 KB
testcase_38 AC 3 ms
5,980 KB
testcase_39 AC 4 ms
5,952 KB
testcase_40 AC 3 ms
6,004 KB
testcase_41 AC 6 ms
6,228 KB
testcase_42 AC 6 ms
6,116 KB
testcase_43 AC 6 ms
6,056 KB
testcase_44 AC 6 ms
6,068 KB
testcase_45 AC 4 ms
5,948 KB
testcase_46 AC 7 ms
6,288 KB
testcase_47 AC 8 ms
6,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;
int S[101010];
int P[101010];
int U[101010];
int did[101010];
vector<pair<pair<int,int>,int>> E[101010];


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	FOR(i,N) {
		cin>>S[i]>>P[i]>>U[i];
		E[U[i]].push_back({{S[i],-P[i]},i});
	}
	priority_queue<pair<pair<int,int>,pair<int,int>>> Q;
	FOR(i,101000) if(E[i].size()) {
		sort(ALL(E[i]));
		x = E[i].back().second;
		E[i].pop_back();
		Q.push({{S[x],0},{-P[x],x}});
	}
	while(K--) {
		auto k=Q.top();
		Q.pop();
		x=k.second.second;
		_P("%d\n",x);
		if(E[U[x]].size()) {
			did[U[x]]++;
			y = E[U[x]].back().second;
			E[U[x]].pop_back();
			Q.push({{S[y],-did[U[y]]},{-P[y],y}});
		}
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}
0