結果

問題 No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
ユーザー kzyKTkzyKT
提出日時 2016-10-14 23:03:18
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 66 ms / 4,000 ms
コード長 1,761 bytes
コンパイル時間 1,690 ms
コンパイル使用メモリ 156,416 KB
実行使用メモリ 10,640 KB
最終ジャッジ日時 2023-08-14 12:31:14
合計ジャッジ時間 5,063 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
10,548 KB
testcase_01 AC 57 ms
10,440 KB
testcase_02 AC 44 ms
9,884 KB
testcase_03 AC 48 ms
9,564 KB
testcase_04 AC 47 ms
9,472 KB
testcase_05 AC 49 ms
10,304 KB
testcase_06 AC 66 ms
10,640 KB
testcase_07 AC 52 ms
10,548 KB
testcase_08 AC 45 ms
10,284 KB
testcase_09 AC 41 ms
9,456 KB
testcase_10 AC 37 ms
9,116 KB
testcase_11 AC 40 ms
8,664 KB
testcase_12 AC 40 ms
8,672 KB
testcase_13 AC 32 ms
9,020 KB
testcase_14 AC 35 ms
8,820 KB
testcase_15 AC 29 ms
8,508 KB
testcase_16 AC 42 ms
8,788 KB
testcase_17 AC 42 ms
8,972 KB
testcase_18 AC 43 ms
9,152 KB
testcase_19 AC 32 ms
9,180 KB
testcase_20 AC 34 ms
8,888 KB
testcase_21 AC 33 ms
8,916 KB
testcase_22 AC 39 ms
8,652 KB
testcase_23 AC 35 ms
8,984 KB
testcase_24 AC 31 ms
8,648 KB
testcase_25 AC 38 ms
8,480 KB
testcase_26 AC 33 ms
8,760 KB
testcase_27 AC 37 ms
8,428 KB
testcase_28 AC 32 ms
9,080 KB
testcase_29 AC 39 ms
8,836 KB
testcase_30 AC 4 ms
7,236 KB
testcase_31 AC 4 ms
7,200 KB
testcase_32 AC 44 ms
9,440 KB
testcase_33 AC 44 ms
8,820 KB
testcase_34 AC 42 ms
9,576 KB
testcase_35 AC 4 ms
7,232 KB
testcase_36 AC 4 ms
7,452 KB
testcase_37 AC 4 ms
7,244 KB
testcase_38 AC 4 ms
7,368 KB
testcase_39 AC 5 ms
7,248 KB
testcase_40 AC 5 ms
7,356 KB
testcase_41 AC 6 ms
7,496 KB
testcase_42 AC 7 ms
7,464 KB
testcase_43 AC 7 ms
7,384 KB
testcase_44 AC 7 ms
7,328 KB
testcase_45 AC 4 ms
7,244 KB
testcase_46 AC 9 ms
7,480 KB
testcase_47 AC 9 ms
7,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
template<C T>void pr(T a){cout<<a;ln;}
template<C T,C T2>void pr(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;
typedef pair<int,P> PP;
typedef pair<P,PP> P2;

void Main() {
  int n,m;
  cin >> n >> m;
  priority_queue<PP,vector<PP>,greater<PP> > v[111111];
  rep(i,n) {
    int x,y,z;
    cin >> x >> y >> z;
    v[z].push(PP(-x,P(y,i)));
  }
  priority_queue<P2,vector<P2>,greater<P2> > que;
  int c[111111];
  mem(c);
  rep(i,111111) {
    if(!v[i].empty()) {
      PP p=v[i].top();v[i].pop();
      que.push(P2(P(p.F,c[i]),PP(p.S.F,P(i,p.S.S))));
    }
  }
  int k=0;
  while(k<m&&!que.empty()) {
    P2 pp=que.top();que.pop();
    pr(pp.S.S.S);
    k++;
    c[pp.S.S.F]++;
    if(!v[pp.S.S.F].empty()) {
      PP p=v[pp.S.S.F].top();v[pp.S.S.F].pop();
      que.push(P2(P(p.F,c[pp.S.S.F]),PP(p.S.F,P(pp.S.S.F,p.S.S))));
    } 
  }
}

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