結果

問題 No.9 モンスターのレベル上げ
ユーザー hanyuhanyu
提出日時 2020-12-26 17:01:21
言語 C++17
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 493 ms / 5,000 ms
コード長 903 bytes
コンパイル時間 1,880 ms
使用メモリ 3,632 KB
最終ジャッジ日時 2022-11-23 15:42:19
合計ジャッジ時間 7,316 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 1 ms
3,548 KB
testcase_01 AC 1 ms
3,496 KB
testcase_02 AC 493 ms
3,584 KB
testcase_03 AC 388 ms
3,600 KB
testcase_04 AC 201 ms
3,560 KB
testcase_05 AC 131 ms
3,600 KB
testcase_06 AC 46 ms
3,480 KB
testcase_07 AC 2 ms
3,464 KB
testcase_08 AC 61 ms
3,416 KB
testcase_09 AC 470 ms
3,632 KB
testcase_10 AC 1 ms
3,388 KB
testcase_11 AC 403 ms
3,596 KB
testcase_12 AC 301 ms
3,508 KB
testcase_13 AC 204 ms
3,564 KB
testcase_14 AC 483 ms
3,588 KB
testcase_15 AC 445 ms
3,492 KB
testcase_16 AC 8 ms
3,408 KB
testcase_17 AC 283 ms
3,588 KB
testcase_18 AC 235 ms
3,592 KB
testcase_19 AC 5 ms
3,508 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