結果
問題 | No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい |
ユーザー | siman |
提出日時 | 2023-01-30 20:08:51 |
言語 | C++17(clang) (17.0.6 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 149 ms / 4,000 ms |
コード長 | 2,384 bytes |
コンパイル時間 | 5,252 ms |
コンパイル使用メモリ | 143,488 KB |
実行使用メモリ | 11,176 KB |
最終ジャッジ日時 | 2024-06-30 05:24:14 |
合計ジャッジ時間 | 8,801 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 140 ms
9,932 KB |
testcase_01 | AC | 128 ms
9,816 KB |
testcase_02 | AC | 93 ms
9,728 KB |
testcase_03 | AC | 117 ms
9,960 KB |
testcase_04 | AC | 116 ms
9,728 KB |
testcase_05 | AC | 106 ms
9,928 KB |
testcase_06 | AC | 149 ms
11,176 KB |
testcase_07 | AC | 101 ms
9,812 KB |
testcase_08 | AC | 91 ms
10,808 KB |
testcase_09 | AC | 99 ms
9,728 KB |
testcase_10 | AC | 96 ms
9,216 KB |
testcase_11 | AC | 111 ms
8,960 KB |
testcase_12 | AC | 104 ms
9,260 KB |
testcase_13 | AC | 72 ms
9,136 KB |
testcase_14 | AC | 84 ms
9,212 KB |
testcase_15 | AC | 62 ms
8,344 KB |
testcase_16 | AC | 126 ms
8,948 KB |
testcase_17 | AC | 128 ms
9,572 KB |
testcase_18 | AC | 130 ms
9,472 KB |
testcase_19 | AC | 73 ms
9,208 KB |
testcase_20 | AC | 82 ms
9,436 KB |
testcase_21 | AC | 81 ms
9,088 KB |
testcase_22 | AC | 114 ms
9,088 KB |
testcase_23 | AC | 94 ms
9,344 KB |
testcase_24 | AC | 70 ms
9,088 KB |
testcase_25 | AC | 106 ms
8,960 KB |
testcase_26 | AC | 81 ms
8,680 KB |
testcase_27 | AC | 100 ms
8,960 KB |
testcase_28 | AC | 71 ms
9,216 KB |
testcase_29 | AC | 105 ms
8,960 KB |
testcase_30 | AC | 5 ms
6,940 KB |
testcase_31 | AC | 5 ms
6,940 KB |
testcase_32 | AC | 123 ms
10,200 KB |
testcase_33 | AC | 127 ms
9,336 KB |
testcase_34 | AC | 98 ms
9,840 KB |
testcase_35 | AC | 5 ms
6,944 KB |
testcase_36 | AC | 4 ms
6,944 KB |
testcase_37 | AC | 5 ms
6,944 KB |
testcase_38 | AC | 4 ms
6,940 KB |
testcase_39 | AC | 5 ms
6,940 KB |
testcase_40 | AC | 5 ms
6,944 KB |
testcase_41 | AC | 11 ms
6,944 KB |
testcase_42 | AC | 12 ms
6,940 KB |
testcase_43 | AC | 12 ms
7,036 KB |
testcase_44 | AC | 11 ms
7,040 KB |
testcase_45 | AC | 6 ms
6,940 KB |
testcase_46 | AC | 23 ms
7,084 KB |
testcase_47 | AC | 22 ms
7,040 KB |
ソースコード
#include <cassert> #include <cmath> #include <algorithm> #include <iostream> #include <iomanip> #include <climits> #include <map> #include <queue> #include <set> #include <cstring> #include <vector> using namespace std; typedef long long ll; struct Node { int id; int solved_cnt; int penalty; int uid; Node(int id = -1, int solved_cnt = -1, int penalty = -1, int uid = -1) { this->id = id; this->solved_cnt = solved_cnt; this->penalty = penalty; this->uid = uid; } bool operator>(const Node &n) const { if (solved_cnt == n.solved_cnt) { return penalty > n.penalty; } else { return solved_cnt < n.solved_cnt; } } }; struct SubNode { int id; int uid; int selected_cnt; int penalty; SubNode(int id = -1, int uid = -1, int selected_cnt = -1, int penalty = -1) { this->id = id; this->uid = uid; this->selected_cnt = selected_cnt; this->penalty = penalty; } bool operator>(const SubNode &n) const { if (selected_cnt == n.selected_cnt) { return penalty > n.penalty; } else { return selected_cnt > n.selected_cnt; } } }; int main() { int N, K; cin >> N >> K; priority_queue <Node, vector<Node>, greater<Node>> pque_list[100010]; for (int i = 0; i < N; ++i) { int S, P, U; cin >> S >> P >> U; pque_list[U].push(Node(i, S, P, U)); } vector<int> selected_ids; vector<int> selected_counter(100010, 0); for (int s = 10; s >= 0; --s) { priority_queue <SubNode, vector<SubNode>, greater<SubNode>> pque; for (int uid = 1; uid <= 100000; ++uid) { if (pque_list[uid].empty()) continue; if (pque_list[uid].top().solved_cnt < s) continue; Node node = pque_list[uid].top(); pque_list[uid].pop(); pque.push(SubNode(node.id, uid, selected_counter[uid], node.penalty)); } while (not pque.empty() && selected_ids.size() < K) { SubNode s_node = pque.top(); pque.pop(); int uid = s_node.uid; selected_ids.push_back(s_node.id); selected_counter[uid]++; if (pque_list[uid].size() > 0 && pque_list[uid].top().solved_cnt >= s) { Node node = pque_list[uid].top(); pque_list[uid].pop(); pque.push(SubNode(node.id, uid, selected_counter[uid], node.penalty)); } } } for (int id : selected_ids) { cout << id << endl; } return 0; }