結果

問題 No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
ユーザー fumofumofunifumofumofuni
提出日時 2022-07-24 18:07:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 271 ms / 4,000 ms
コード長 1,881 bytes
コンパイル時間 3,004 ms
コンパイル使用メモリ 227,204 KB
実行使用メモリ 22,476 KB
最終ジャッジ日時 2023-09-20 18:00:07
合計ジャッジ時間 11,236 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 217 ms
15,732 KB
testcase_01 AC 192 ms
15,648 KB
testcase_02 AC 150 ms
15,228 KB
testcase_03 AC 179 ms
15,228 KB
testcase_04 AC 179 ms
15,144 KB
testcase_05 AC 169 ms
15,564 KB
testcase_06 AC 271 ms
22,476 KB
testcase_07 AC 158 ms
15,124 KB
testcase_08 AC 167 ms
20,572 KB
testcase_09 AC 143 ms
17,592 KB
testcase_10 AC 120 ms
16,784 KB
testcase_11 AC 138 ms
16,808 KB
testcase_12 AC 128 ms
14,504 KB
testcase_13 AC 90 ms
16,332 KB
testcase_14 AC 104 ms
14,172 KB
testcase_15 AC 79 ms
16,500 KB
testcase_16 AC 142 ms
16,688 KB
testcase_17 AC 145 ms
16,884 KB
testcase_18 AC 146 ms
16,952 KB
testcase_19 AC 88 ms
16,468 KB
testcase_20 AC 100 ms
14,080 KB
testcase_21 AC 96 ms
16,600 KB
testcase_22 AC 131 ms
16,420 KB
testcase_23 AC 111 ms
16,440 KB
testcase_24 AC 88 ms
16,484 KB
testcase_25 AC 122 ms
16,540 KB
testcase_26 AC 97 ms
16,504 KB
testcase_27 AC 119 ms
16,340 KB
testcase_28 AC 89 ms
16,788 KB
testcase_29 AC 126 ms
17,012 KB
testcase_30 AC 5 ms
10,832 KB
testcase_31 AC 4 ms
11,008 KB
testcase_32 AC 157 ms
14,872 KB
testcase_33 AC 170 ms
17,084 KB
testcase_34 AC 139 ms
18,172 KB
testcase_35 AC 4 ms
10,680 KB
testcase_36 AC 5 ms
10,740 KB
testcase_37 AC 5 ms
10,860 KB
testcase_38 AC 5 ms
11,012 KB
testcase_39 AC 6 ms
10,804 KB
testcase_40 AC 6 ms
11,068 KB
testcase_41 AC 13 ms
11,392 KB
testcase_42 AC 13 ms
11,788 KB
testcase_43 AC 13 ms
11,536 KB
testcase_44 AC 12 ms
11,284 KB
testcase_45 AC 6 ms
11,000 KB
testcase_46 AC 29 ms
11,544 KB
testcase_47 AC 28 ms
11,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=(n)-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,1,0,-1,1,-1,1,-1};
template <typename T> inline bool chmax(T &a, T b) {
  return ((a < b) ? (a = b, true) : (false));
}
template <typename T> inline bool chmin(T &a, T b) {
  return ((a > b) ? (a = b, true) : (false));
}

struct node{
  ll p,u,id;
  bool operator<(node &b){
    return p<b.p;
  }
};
int main(){
  ll n,k;cin >> n >> k;
  map<ll,vector<node>> mp;
  rep(i,n){
    ll s,p,u;cin >> s >> p >> u;
    mp[-s].push_back({p,u,i});
  }
  vl use;
  vl solve(1e6);
  for(auto [hoge,v]:mp){
    map<ll,vector<node>> univ;//大学ごと
    for(auto p:v){
      univ[p.u].emplace_back(p);
    }
    for(auto &p:univ)sort(all(p.second)),rev(all(p.second));
    set<tuple<ll,ll,ll>> st;
    for(auto p:univ){
      st.insert(make_tuple(solve[p.second.back().u],p.second.back().p,p.first));
    }
    while(k){
      if(st.size()==0)break;
      auto f=*st.begin();st.erase(st.begin());
      auto un=get<2>(f);
      solve[un]++;use.emplace_back(univ[un].back().id);
      univ[un].pop_back();
      if(univ[un].size()){
        st.insert(make_tuple(solve[univ[un].back().u],univ[un].back().p,un));
      }
      k--;
    }
  }
  for(auto p:use)cout << p << endl;
}
0