結果

問題 No.9 モンスターのレベル上げ
ユーザー 久我山菜々久我山菜々
提出日時 2018-09-30 18:05:44
言語 C++17
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 289 ms / 5,000 ms
コード長 979 bytes
コンパイル時間 975 ms
使用メモリ 3,560 KB
最終ジャッジ日時 2022-12-05 11:21:24
合計ジャッジ時間 4,907 ms
ジャッジサーバーID
(参考情報)
judge12 / judge16
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
3,540 KB
testcase_01 AC 1 ms
3,520 KB
testcase_02 AC 289 ms
3,476 KB
testcase_03 AC 230 ms
3,472 KB
testcase_04 AC 121 ms
3,464 KB
testcase_05 AC 79 ms
3,544 KB
testcase_06 AC 28 ms
3,384 KB
testcase_07 AC 2 ms
3,528 KB
testcase_08 AC 37 ms
3,384 KB
testcase_09 AC 283 ms
3,408 KB
testcase_10 AC 2 ms
3,440 KB
testcase_11 AC 204 ms
3,476 KB
testcase_12 AC 135 ms
3,508 KB
testcase_13 AC 134 ms
3,404 KB
testcase_14 AC 284 ms
3,560 KB
testcase_15 AC 256 ms
3,552 KB
testcase_16 AC 6 ms
3,556 KB
testcase_17 AC 165 ms
3,400 KB
testcase_18 AC 139 ms
3,504 KB
testcase_19 AC 4 ms
3,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>

int main(int, char**) {
  int n;
  std::cin >> n;
  std::vector<std::pair<int, int>> as(n);
  std::vector<int> bs(n);
  for(int i{}; i < n; ++i) {
    int a;
    std::cin >> a;
    as[i] = std::make_pair(a, 0);
  }
  for(int i{}; i < n; ++i) {
    std::cin >> bs[i];
  }

  int min{10000000};
  make_heap(begin(as), end(as), std::greater<std::pair<int, int>>());
  for(int i{}; i < n; ++i) {
    std::vector<std::pair<int, int>> nas = as;
    for(int j{}; j < n; ++j) {
      int vsl = bs[(j + i) % n];
      nas[0].first += vsl / 2;
      nas[0].second += 1;
      pop_heap(begin(nas), end(nas), std::greater<std::pair<int, int>>());
      push_heap(begin(nas), end(nas), std::greater<std::pair<int, int>>());
    }
    sort(begin(nas), end(nas), [](auto x, auto y){ return x.second > y.second; });
    min = std::min(min, nas[0].second);
  }
  std::cout << min <<std::endl;

  return 0;
}

0