結果

問題 No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
ユーザー 0w10w1
提出日時 2016-12-16 01:23:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,033 bytes
コンパイル時間 3,621 ms
コンパイル使用メモリ 189,988 KB
実行使用メモリ 10,268 KB
最終ジャッジ日時 2023-08-20 08:33:16
合計ジャッジ時間 8,226 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 42 ms
8,776 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 116 ms
10,268 KB
testcase_07 AC 45 ms
8,940 KB
testcase_08 AC 47 ms
9,888 KB
testcase_09 AC 61 ms
9,216 KB
testcase_10 AC 68 ms
8,992 KB
testcase_11 AC 85 ms
9,048 KB
testcase_12 WA -
testcase_13 AC 40 ms
8,812 KB
testcase_14 WA -
testcase_15 AC 32 ms
8,660 KB
testcase_16 AC 95 ms
8,992 KB
testcase_17 AC 93 ms
9,300 KB
testcase_18 AC 97 ms
9,256 KB
testcase_19 AC 39 ms
8,928 KB
testcase_20 WA -
testcase_21 AC 46 ms
8,928 KB
testcase_22 AC 81 ms
8,876 KB
testcase_23 AC 60 ms
8,860 KB
testcase_24 AC 39 ms
8,940 KB
testcase_25 AC 73 ms
8,940 KB
testcase_26 AC 50 ms
8,940 KB
testcase_27 AC 74 ms
8,980 KB
testcase_28 AC 38 ms
8,924 KB
testcase_29 AC 81 ms
9,068 KB
testcase_30 AC 5 ms
6,516 KB
testcase_31 AC 4 ms
6,724 KB
testcase_32 WA -
testcase_33 AC 99 ms
9,164 KB
testcase_34 AC 50 ms
9,280 KB
testcase_35 AC 5 ms
6,428 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 5 ms
6,632 KB
testcase_39 AC 5 ms
6,720 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 9 ms
6,856 KB
testcase_43 AC 9 ms
6,920 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

typedef long long ll;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< ll > vl;
typedef vector< vl > vvl;
typedef pair< int, int > pii;
typedef vector< pii > vp;
typedef vector< double > vd;
typedef vector< vd > vvd;
typedef vector< string > vs;

template< class T1, class T2 >
int upmin( T1 &x, T2 v ){
  if( x > v ){
    x = v;
    return 1;
  }
  return 0;
}

template< class T1, class T2 >
int upmax( T1 &x, T2 v ){
  if( x < v ){
    x = v;
    return 1;
  }
  return 0;
}

const int INF = 0x3f3f3f3f;

int N, K;
vi S, P, U;

void init(){
  cin >> N >> K;
  S = P = U = vi( N );
  for( int i = 0; i < N; ++i )
    cin >> S[ i ] >> P[ i ] >> U[ i ];
}

vi ans;

void preprocess(){
  vvi s2id( 10 + 1 );
  for( int i = 0; i < N; ++i )
    s2id[ S[ i ] ].emplace_back( i );
  for( int i = 10; i >= 0; --i ){
    if( ans.size() + s2id[ i ].size() <= K ){
      for( int j = 0; j < s2id[ i ].size(); ++j )
        ans.emplace_back( s2id[ i ][ j ] );
    } else{
      vi ucnt( ( int ) 1e5 + 1 );
      for( int j = 0; j < ans.size(); ++j )
        ++ucnt[ U[ ans[ j ] ] ];
      vector< priority_queue< tuple< int, int > > > pq( ( int ) 1e5 + 1 );
      for( int j = 0; j < N; ++j )
        if( S[ j ] == i )
          pq[ U[ j ] ].emplace( -P[ j ], j );
      priority_queue< tuple< int, int, int > > upq;
      for( int j = 0; j <= ( int ) 1e5; ++j )
        if( not pq[ j ].empty() )
          upq.emplace( -ucnt[ j ], get< 0 >( pq[ j ].top() ), j );
      while( not upq.empty() and ans.size() < K ){
        int uc, p, u; tie( uc, p, u ) = upq.top(); upq.pop();
        int x, id; tie( x, id ) = pq[ u ].top(); pq[ u ].pop();
        ans.emplace_back( id );
        if( not pq[ u ].empty() )
          upq.emplace( uc - 1, get< 0 >( pq[ u ].top() ), u );
      }
      break;
    }
  }
}

void solve(){
  for( int i = 0; i < K; ++i )
    cout << ans[ i ] << endl;
}

signed main(){
  ios::sync_with_stdio( 0 );
  init();
  preprocess();
  solve();
  return 0;
}
0