結果

問題 No.9 モンスターのレベル上げ
ユーザー hanyuhanyu
提出日時 2020-12-26 17:01:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 438 ms / 5,000 ms
コード長 903 bytes
コンパイル時間 2,653 ms
コンパイル使用メモリ 208,332 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-25 00:45:16
合計ジャッジ時間 7,426 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 438 ms
4,372 KB
testcase_03 AC 351 ms
4,372 KB
testcase_04 AC 183 ms
4,372 KB
testcase_05 AC 119 ms
4,372 KB
testcase_06 AC 41 ms
4,372 KB
testcase_07 AC 2 ms
4,372 KB
testcase_08 AC 54 ms
4,372 KB
testcase_09 AC 426 ms
4,372 KB
testcase_10 AC 2 ms
4,372 KB
testcase_11 AC 364 ms
4,372 KB
testcase_12 AC 292 ms
4,372 KB
testcase_13 AC 197 ms
4,372 KB
testcase_14 AC 425 ms
4,372 KB
testcase_15 AC 389 ms
4,372 KB
testcase_16 AC 8 ms
4,372 KB
testcase_17 AC 249 ms
4,372 KB
testcase_18 AC 208 ms
4,372 KB
testcase_19 AC 5 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  for (int i = 0; i < n; i++) cin >> b.at(i);
  
  int ans = 1e9;
  for (int start = 0; start < n; start++) {
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
    for (int i = 0; i < n; i++) pq.push(make_pair(a[i], 0));
    
    for (int add = 0; add < n; add++) {
      int now = (start + add) % n;
      auto [level, count] = pq.top();
      pq.pop();
      level += b[now] / 2;
      count++;
      pq.push(make_pair(level, count));
    }
    
    int countmax = 0;
    while (!pq.empty()) {
      auto [level, count] = pq.top();
      pq.pop();
      countmax = max(countmax, count);
    }
    
    ans = min(ans, countmax);
  }
  
  cout << ans << '\n';
}
0