結果

問題 No.9 モンスターのレベル上げ
ユーザー iqueue02
提出日時 2019-12-25 14:56:38
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 437 ms / 5,000 ms
コード長 785 bytes
コンパイル時間 1,635 ms
コンパイル使用メモリ 175,112 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-25 02:18:46
合計ジャッジ時間 6,219 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n;
  cin >> n;
  vector<int> a(2*n), b(2*n);
  rep(i,n) cin >> a[i], a[i + n] = a[i];
  rep(i,n) cin >> b[i], b[i + n] = b[i];
  
  int res = 1e9;
  for (int i = 0; i < n; i++) {
    priority_queue<P, vector<P>, greater<P>> que;
    for (int j = 0; j < n; j++) que.push(make_pair(a[j],0));
    for (int j = i; j < i + n; j++) {
      P p = que.top(); que.pop();
      p.first += b[j] / 2;
      p.second++;
      que.push(p);
    }
    int mx = 0;
    while (!que.empty()) {
      mx = max(mx, que.top().second);
      que.pop();
    }
    res = min(res, mx);
  }
  cout << res << endl;
  return 0;
}
0