結果
問題 | No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい |
ユーザー |
|
提出日時 | 2016-10-14 23:35:13 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 203 ms / 4,000 ms |
コード長 | 1,171 bytes |
コンパイル時間 | 1,263 ms |
コンパイル使用メモリ | 95,120 KB |
実行使用メモリ | 12,032 KB |
最終ジャッジ日時 | 2024-11-22 06:30:16 |
合計ジャッジ時間 | 7,629 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 48 |
ソースコード
#include <iostream>#include <vector>#include <algorithm>#include <map>#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))#define whole(f,x,...) ([&](decltype((x)) y) { return (f)(begin(y), end(y), ## __VA_ARGS__); })(x)using namespace std;struct team_t {int solved, penalty, university;int index, rank_in_university;};bool operator < (team_t const & a, team_t const & b) {return make_tuple(- a.solved, a.rank_in_university, a.penalty, a.index, a.university)< make_tuple(- b.solved, b.rank_in_university, b.penalty, a.index, b.university); // reversed}int main() {int n, k; cin >> n >> k;vector<team_t> team(n);repeat (i,n) {cin >> team[i].solved >> team[i].penalty >> team[i].university;team[i].index = i;}map<int,vector<int> > univ;repeat (i,n) univ[team[i].university].push_back(i);for (auto & it : univ) {vector<int> & ix = it.second;whole(sort, ix, [&](int i, int j) { return team[i] < team[j]; });repeat (j, ix.size()) team[ix[j]].rank_in_university = j;}whole(sort, team);repeat (i,k) cout << team[i].index << endl;return 0;}