結果
問題 | No.9 モンスターのレベル上げ |
ユーザー | 久我山菜々 |
提出日時 | 2018-09-30 18:05:44 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 240 ms / 5,000 ms |
コード長 | 979 bytes |
コンパイル時間 | 931 ms |
コンパイル使用メモリ | 108,524 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-04-20 13:44:10 |
合計ジャッジ時間 | 3,683 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 1 ms
6,940 KB |
testcase_02 | AC | 240 ms
6,944 KB |
testcase_03 | AC | 191 ms
6,944 KB |
testcase_04 | AC | 99 ms
6,940 KB |
testcase_05 | AC | 67 ms
6,944 KB |
testcase_06 | AC | 24 ms
6,940 KB |
testcase_07 | AC | 2 ms
6,944 KB |
testcase_08 | AC | 31 ms
6,940 KB |
testcase_09 | AC | 234 ms
6,940 KB |
testcase_10 | AC | 2 ms
6,940 KB |
testcase_11 | AC | 159 ms
6,940 KB |
testcase_12 | AC | 109 ms
6,940 KB |
testcase_13 | AC | 134 ms
6,940 KB |
testcase_14 | AC | 236 ms
6,940 KB |
testcase_15 | AC | 221 ms
6,940 KB |
testcase_16 | AC | 5 ms
6,940 KB |
testcase_17 | AC | 138 ms
6,944 KB |
testcase_18 | AC | 113 ms
6,944 KB |
testcase_19 | AC | 4 ms
6,940 KB |
ソースコード
#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; }