結果

問題 No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
ユーザー しらっ亭しらっ亭
提出日時 2016-10-14 23:00:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,141 bytes
コンパイル時間 2,865 ms
コンパイル使用メモリ 201,160 KB
実行使用メモリ 12,536 KB
最終ジャッジ日時 2024-05-02 00:21:53
合計ジャッジ時間 8,584 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 2 ms
5,376 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 6 ms
5,376 KB
testcase_44 AC 7 ms
5,376 KB
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;using vb=vector<bool>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
template <typename T> T read() {T t; cin >> t; return t;}

using iii = pair<int, pii>;

void Main() {
  int N = read<int>();
  int K = read<int>();

  map<int, vector<iii>> smap;
  map<int, int> uc;

  rep(i, N) {
    int s = read<int>();
    int p = read<int>();
    int u = read<int>();
    smap[-s].push_back({u, {p, i}});
  }

  vi ans;
  forr(st, smap) {
    vector<iii> &teams = st.snd;
    vi us;
    map<int, vpii> uteams;
    forr(t, teams) {
      us.push_back(t.fst);
      uteams[t.fst].push_back(t.snd);
    }
    sort(ALL(us));
    us.erase(unique(us.begin(), us.end()), us.end());

    priority_queue<pii, vector<pii>, greater<pii> > q;
    forr(u, us) {
      q.emplace(uc[u], u);
      sort(ALL(uteams[u]));
      reverse(ALL(uteams[u]));
    }

    while (!q.empty() && K) {
      int u = q.top().snd;
      q.pop();
      vpii &teams = uteams[u];
      if (SZ(teams) != 0) {
        int idx = teams[SZ(teams)-1].snd;
        ans.push_back(idx);
        teams.pop_back();
        uc[u]++;
        q.emplace(uc[u], u);
        K--;
      }
    }
  }

  forr(i, ans) cout << i << endl;

}
int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }
0