結果

問題 No.9 モンスターのレベル上げ
ユーザー 久我山菜々久我山菜々
提出日時 2018-09-30 18:25:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 362 ms / 5,000 ms
コード長 937 bytes
コンパイル時間 1,221 ms
コンパイル使用メモリ 107,192 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 13:45:12
合計ジャッジ時間 5,038 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 362 ms
5,376 KB
testcase_03 AC 295 ms
5,376 KB
testcase_04 AC 157 ms
5,376 KB
testcase_05 AC 103 ms
5,376 KB
testcase_06 AC 36 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 45 ms
5,376 KB
testcase_09 AC 359 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 277 ms
5,376 KB
testcase_12 AC 213 ms
5,376 KB
testcase_13 AC 169 ms
5,376 KB
testcase_14 AC 353 ms
5,376 KB
testcase_15 AC 327 ms
5,376 KB
testcase_16 AC 7 ms
5,376 KB
testcase_17 AC 207 ms
5,376 KB
testcase_18 AC 170 ms
5,376 KB
testcase_19 AC 5 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

static int const INF{100000000};

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

  int min{10000000};
  for(int i{}; i < n; ++i) {
    auto nas = as;
    for(int j{}; j < n; ++j) {
      int vsl = bs[(j + i) % n];
      auto nt = nas.top();
      nas.pop();
      nt.first += vsl / 2;
      nt.second += 1;
      nas.push(nt);
    }

    int m{};
    for(int i{}; i < n; ++i) {
      m = std::max(m, nas.top().second);
      nas.pop();
    }
    
    min = std::min(min, m);
  }
  std::cout << min <<std::endl;

  return 0;
}

0