結果

問題 No.9 モンスターのレベル上げ
ユーザー k
提出日時 2014-10-30 09:14:04
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 223 ms / 5,000 ms
コード長 957 bytes
コンパイル時間 747 ms
コンパイル使用メモリ 77,748 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-23 22:00:49
合計ジャッジ時間 3,332 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <string>

using namespace std;

int main() {
  int n;
  cin >> n;
  priority_queue <pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > a;
  int b[n];
  for (int i = 0; i < n; i++) {
    int t; cin >> t; a.push(make_pair(t, 0));
  }
  for (int i = 0; i < n; i++) cin >> b[i];

  int ans = 1e9;
  for (int i = 0; i < n; i++) {
    int t = 0;
    priority_queue <pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > ta = a;
    for (int j = 0; j < n; j++) {
      pair <int, int> p = ta.top(); ta.pop();
      p.first += b[(i+j)%n]/2;
      p.second++;
      t = max(t, p.second);
      ta.push(p);
    }
    ans = min(ans, t);
  }
  cout << ans << endl;
}
0