結果

問題 No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
ユーザー femtofemto
提出日時 2016-10-15 00:26:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 185 ms / 4,000 ms
コード長 1,473 bytes
コンパイル時間 1,614 ms
コンパイル使用メモリ 112,380 KB
実行使用メモリ 75,056 KB
最終ジャッジ日時 2024-05-02 00:17:50
合計ジャッジ時間 8,888 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 178 ms
73,856 KB
testcase_01 AC 154 ms
73,552 KB
testcase_02 AC 114 ms
73,472 KB
testcase_03 AC 139 ms
73,460 KB
testcase_04 AC 136 ms
73,336 KB
testcase_05 AC 134 ms
73,472 KB
testcase_06 AC 185 ms
74,308 KB
testcase_07 AC 123 ms
73,520 KB
testcase_08 AC 116 ms
73,740 KB
testcase_09 AC 116 ms
73,216 KB
testcase_10 AC 131 ms
75,008 KB
testcase_11 AC 148 ms
74,940 KB
testcase_12 AC 146 ms
74,880 KB
testcase_13 AC 105 ms
74,752 KB
testcase_14 AC 125 ms
74,880 KB
testcase_15 AC 101 ms
74,752 KB
testcase_16 AC 160 ms
74,864 KB
testcase_17 AC 160 ms
75,056 KB
testcase_18 AC 158 ms
74,916 KB
testcase_19 AC 107 ms
74,752 KB
testcase_20 AC 119 ms
74,880 KB
testcase_21 AC 114 ms
74,880 KB
testcase_22 AC 143 ms
74,880 KB
testcase_23 AC 123 ms
74,880 KB
testcase_24 AC 107 ms
74,624 KB
testcase_25 AC 137 ms
74,880 KB
testcase_26 AC 123 ms
74,880 KB
testcase_27 AC 144 ms
74,752 KB
testcase_28 AC 110 ms
74,624 KB
testcase_29 AC 145 ms
74,880 KB
testcase_30 AC 64 ms
73,088 KB
testcase_31 AC 61 ms
73,088 KB
testcase_32 AC 164 ms
74,752 KB
testcase_33 AC 164 ms
74,872 KB
testcase_34 AC 108 ms
73,472 KB
testcase_35 AC 60 ms
73,088 KB
testcase_36 AC 60 ms
73,088 KB
testcase_37 AC 59 ms
73,088 KB
testcase_38 AC 61 ms
73,216 KB
testcase_39 AC 61 ms
73,088 KB
testcase_40 AC 61 ms
72,960 KB
testcase_41 AC 67 ms
73,216 KB
testcase_42 AC 72 ms
73,216 KB
testcase_43 AC 73 ms
73,216 KB
testcase_44 AC 73 ms
73,216 KB
testcase_45 AC 68 ms
73,088 KB
testcase_46 AC 89 ms
73,472 KB
testcase_47 AC 87 ms
73,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <map>
#include <set>
#include <queue>
using namespace std;

struct T {
	int s, p, u, id;
	bool operator < (const T& t) const {
		if(s != t.s) return s > t.s;
		return p < t.p;
	}
};

deque<T> ts[100010];
int sum[11];
int sel[100010];
vector<int> rnk[100010];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, K;
	cin >> N >> K;

	for(int i = 0; i < N; i++) {
		T t;
		cin >> t.s >> t.p >> t.u;
		t.id = i;
		ts[t.u].push_back(t);
		sum[t.s]++;
	}
	for(int i = 0; i < 100010; i++) {
		sort(ts[i].begin(), ts[i].end());
	}

	vector<int> ans;
	while(1) {
		for(int s = 10; s >= 0; s--) {
			if(sum[s] == 0) continue;
			for(int u = 0; u < 100010; u++) {
				if(ts[u].size() && ts[u].front().s == s) rnk[sel[u]].push_back(u);
			}
			for(int r = 0; r < 100010; r++) {
				if(rnk[r].size() == 0) continue;
				vector<T> temp;
				for(int u : rnk[r]) {
					temp.push_back(ts[u][0]);
				}
				sort(temp.begin(), temp.end());
				for(T t : temp) {
					ans.push_back(t.id);
					if(ans.size() == K) {
						for(int v : ans) {
							cout << v << endl;
						}
						return 0;
					}

					sum[s]--;
					ts[t.u].pop_front();
					sel[t.u]++;
					if(ts[t.u].size() && ts[t.u].front().s == s) {
						rnk[sel[t.u]].push_back(t.u);
					}
				}
				rnk[r].clear();
				if(sum[s] == 0) break;
			}
		}
	}
}
0