結果
問題 | No.9 モンスターのレベル上げ |
ユーザー |
|
提出日時 | 2016-03-13 00:42:06 |
言語 | C++11 (gcc 8.5.0) |
結果 |
AC
|
実行時間 | 433 ms / 5,000 ms |
コード長 | 1,415 bytes |
コンパイル時間 | 575 ms |
使用メモリ | 6,952 KB |
最終ジャッジ日時 | 2023-01-21 15:31:11 |
合計ジャッジ時間 | 5,654 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,904 KB |
testcase_01 | AC | 1 ms
6,952 KB |
testcase_02 | AC | 433 ms
6,952 KB |
testcase_03 | AC | 341 ms
4,904 KB |
testcase_04 | AC | 182 ms
6,948 KB |
testcase_05 | AC | 121 ms
4,904 KB |
testcase_06 | AC | 43 ms
4,900 KB |
testcase_07 | AC | 2 ms
6,948 KB |
testcase_08 | AC | 57 ms
6,948 KB |
testcase_09 | AC | 421 ms
4,908 KB |
testcase_10 | AC | 2 ms
4,904 KB |
testcase_11 | AC | 368 ms
6,948 KB |
testcase_12 | AC | 345 ms
4,904 KB |
testcase_13 | AC | 263 ms
4,904 KB |
testcase_14 | AC | 423 ms
6,952 KB |
testcase_15 | AC | 386 ms
4,900 KB |
testcase_16 | AC | 8 ms
4,908 KB |
testcase_17 | AC | 251 ms
4,900 KB |
testcase_18 | AC | 212 ms
4,904 KB |
testcase_19 | AC | 5 ms
4,904 KB |
ソースコード
#include <iostream> #include <algorithm> #include <queue> #include <functional> using namespace std; struct Monster { Monster(int num, int level) { this->num = num; this->level = level; this->count = 0; } int num; int level; int count; }; int main() { int n; cin >> n; int level_allys[1500]; int level_enemys[1500]; int count_levels[1500]; for (int i = 0; i < n; i++) { cin >> level_allys[i]; } for (int i = 0; i < n; i++) { cin >> level_enemys[i]; } typedef function<bool(const Monster&, const Monster&)> predicate_type; predicate_type predicate = [](const Monster& left, const Monster& right) { if (left.level > right.level) { return true; } else if (left.level == right.level && (left.count > right.count)) { return true; } else { return false; } }; int ans = numeric_limits<int>::max(); for (int i = 0; i < n; i++) { priority_queue<Monster, vector<Monster>, predicate_type> q(predicate); for (int j = 0; j < n; j++) { q.push(Monster(j, level_allys[j])); count_levels[j] = 0; } for (int j = 0; j < n; j++) { Monster m = q.top(); q.pop(); int target = (i + j) % n; int level = level_enemys[target]; m.level += level / 2; m.count++; count_levels[m.num] = m.count; q.push(m); } int max_count = *max_element(count_levels, count_levels + n); ans = min(ans, max_count); } cout << ans << endl; return 0; }