結果

問題 No.9 モンスターのレベル上げ
コンテスト
ユーザー C++
提出日時 2024-10-21 01:25:13
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 190 ms / 5,000 ms
コード長 726 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,076 ms
コンパイル使用メモリ 220,384 KB
実行使用メモリ 9,268 KB
最終ジャッジ日時 2026-07-06 00:59:14
合計ジャッジ時間 4,228 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(nullptr)->sync_with_stdio(false);
  using P = pair<int, int>;
  int N; cin >> N;
  int A[N], B[N];
  for(int i = 0; i < N; ++i) cin >> A[i];
  for(int i = 0; i < N; ++i) cin >> B[i];

  int ret = 1e9;
  for(int i = 0; i < N; ++i){
    priority_queue<P, vector<P>, greater<P>> que;
    for(int j = 0; j < N; ++j){
      que.emplace(A[j], 0);
    }

    int res = 0;
    for(int j = 0; j < N; ++j){
      const auto [cur_health, fight_till_now] = que.top();
      que.pop();
      res = max(res, fight_till_now + 1);
      que.emplace(cur_health + B[(i + j) % N] / 2, fight_till_now + 1);
    }
    ret = min(ret, res);
  }
  cout << ret << endl;
  return 0;
}
0