結果

問題 No.9 モンスターのレベル上げ
ユーザー SSRS
提出日時 2020-11-07 22:27:48
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 393 ms / 5,000 ms
コード長 790 bytes
コンパイル時間 2,066 ms
コンパイル使用メモリ 173,648 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-22 14:53:29
合計ジャッジ時間 5,650 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const int INF = 100000;
int 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 = INF;
  for (int i = 0; i < N; i++){
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
    for (int j = 0; j < N; j++){
      pq.push(make_pair(A[j], 0));
    }
    for (int j = 0; j < N; j++){
      int l = pq.top().first;
      int t = pq.top().second;
      pq.pop();
      pq.push(make_pair(l + B[(i + j) % N] / 2, t + 1));
    }
    int mx = 0;
    for (int j = 0; j < N; j++){
      mx = max(mx, pq.top().second);
      pq.pop();
    }
    ans = min(ans, mx);
  }
  cout << ans << endl;
}
0