結果

問題 No.9 モンスターのレベル上げ
ユーザー tsukiotsukio
提出日時 2016-03-13 02:10:40
言語 C++11
(gcc 11.4.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 909 bytes
コンパイル時間 425 ms
コンパイル使用メモリ 64,888 KB
最終ジャッジ日時 2024-04-27 04:56:04
合計ジャッジ時間 743 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:25:19: error: ‘numeric_limits’ was not declared in this scope
   25 |         int ans = numeric_limits<int>::max();
      |                   ^~~~~~~~~~~~~~
main.cpp:25:34: error: expected primary-expression before ‘int’
   25 |         int ans = numeric_limits<int>::max();
      |                                  ^~~

ソースコード

diff #

#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>

using namespace std;
typedef pair<int, int> pii;

int main() {	
	int n;
	cin >> n;

	int level_allys[1500];
	int level_enemys[1500];
	
	for (int i = 0; i < n; i++) {
		cin >> level_allys[i];
	}

	for (int i = 0; i < n; i++) {
		cin >> level_enemys[i];
	}

	priority_queue<pii, vector<pii>, greater<pii>> q;
	int ans = numeric_limits<int>::max();
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			q.push(make_pair(level_allys[j], 0));
		}
		for (int j = 0; j < n; j++) {
			auto pair = q.top();
			q.pop();
			int add = level_enemys[(i + j) % n] / 2;
			q.push(make_pair(pair.first + add, pair.second + 1));
		}

		int max_count = 0;
		while (q.size() > 0) {
			auto pair = q.top();
			q.pop();
			max_count = max(max_count, pair.second);
		}

		ans = min(ans, max_count);
	}

	cout << ans << endl;

	return 0;
}
0