結果

問題 No.9 モンスターのレベル上げ
ユーザー 0w10w1
提出日時 2016-11-27 20:57:58
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 290 ms / 5,000 ms
コード長 815 bytes
コンパイル時間 1,430 ms
使用メモリ 3,524 KB
最終ジャッジ日時 2023-01-21 16:09:20
合計ジャッジ時間 5,049 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
3,372 KB
testcase_01 AC 2 ms
3,428 KB
testcase_02 AC 290 ms
3,416 KB
testcase_03 AC 231 ms
3,416 KB
testcase_04 AC 121 ms
3,400 KB
testcase_05 AC 80 ms
3,392 KB
testcase_06 AC 27 ms
3,376 KB
testcase_07 AC 1 ms
3,436 KB
testcase_08 AC 37 ms
3,452 KB
testcase_09 AC 284 ms
3,464 KB
testcase_10 AC 2 ms
3,508 KB
testcase_11 AC 229 ms
3,516 KB
testcase_12 AC 162 ms
3,472 KB
testcase_13 AC 150 ms
3,484 KB
testcase_14 AC 284 ms
3,524 KB
testcase_15 AC 258 ms
3,468 KB
testcase_16 AC 5 ms
3,488 KB
testcase_17 AC 166 ms
3,464 KB
testcase_18 AC 139 ms
3,480 KB
testcase_19 AC 4 ms
3,448 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