結果

問題 No.9 モンスターのレベル上げ
ユーザー 0w10w1
提出日時 2016-11-27 20:57:58
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 280 ms / 5,000 ms
コード長 815 bytes
コンパイル時間 2,207 ms
コンパイル使用メモリ 172,492 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-06 05:01:59
合計ジャッジ時間 5,016 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 280 ms
4,380 KB
testcase_03 AC 222 ms
4,380 KB
testcase_04 AC 116 ms
4,384 KB
testcase_05 AC 76 ms
4,380 KB
testcase_06 AC 26 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 35 ms
4,384 KB
testcase_09 AC 270 ms
4,384 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 214 ms
4,384 KB
testcase_12 AC 178 ms
4,384 KB
testcase_13 AC 147 ms
4,380 KB
testcase_14 AC 271 ms
4,380 KB
testcase_15 AC 246 ms
4,384 KB
testcase_16 AC 5 ms
4,380 KB
testcase_17 AC 157 ms
4,384 KB
testcase_18 AC 132 ms
4,384 KB
testcase_19 AC 4 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

signed main(){
  int N; cin >> N;
  vector< int > A( N );
  for( int i = 0; i < N; ++i )
    cin >> A[ i ];
  vector< int > B( N );
  for( int i = 0; i < N; ++i )
    cin >> B[ i ];
  int ans = 0x3f3f3f3f;
  for( int i = 0; i < N; ++i ){ // starting point of monster combat
    priority_queue< pair< int, int >, vector< pair< int, int > >, greater< pair< int, int > > > pq;
    for( int j = 0; j < N; ++j )
      pq.emplace( A[ j ], 0 );
    int max_rnd = 0;
    for( int j = i; ; j = ( j + 1 ) % N ){
      int lv, rnd; tie( lv, rnd ) = pq.top(); pq.pop();
      pq.emplace( lv + B[ j ] / 2, rnd + 1 );
      max_rnd = max( max_rnd, rnd + 1 );
      if( ( j + 1 ) % N == i )
        break;
    }
    ans = min( ans, max_rnd );
  }
  cout << ans << endl;
  return 0;
}
0