結果

問題 No.9 モンスターのレベル上げ
ユーザー TatamoTatamo
提出日時 2016-12-13 17:42:18
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 220 ms / 5,000 ms
コード長 1,427 bytes
コンパイル時間 582 ms
コンパイル使用メモリ 70,804 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-06 05:02:36
合計ジャッジ時間 3,429 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 220 ms
4,376 KB
testcase_03 AC 176 ms
4,376 KB
testcase_04 AC 93 ms
4,380 KB
testcase_05 AC 62 ms
4,376 KB
testcase_06 AC 22 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 28 ms
4,376 KB
testcase_09 AC 216 ms
4,380 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 143 ms
4,380 KB
testcase_12 AC 113 ms
4,380 KB
testcase_13 AC 130 ms
4,376 KB
testcase_14 AC 217 ms
4,376 KB
testcase_15 AC 196 ms
4,376 KB
testcase_16 AC 5 ms
4,380 KB
testcase_17 AC 126 ms
4,380 KB
testcase_18 AC 105 ms
4,380 KB
testcase_19 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<utility>
#include<vector>
#include<queue>

using namespace std;
#define cerr cerr << "[DBG] "
#define DBG(x) cerr << #x << ": " << x << endl
// http://genkisugimoto.com/jp/blog/procon/2015/04/15/print-debug-technique-in-cpp.html
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) { for (int i = 0; i < (int)v.size(); ++i) { s << v[i]; if (i < (int)v.size() - 1) s << "\t"; } return s; }

typedef long long ll;
typedef pair<int, int> ip;
typedef priority_queue<ip, vector<ip>, greater<ip>> pq_ip;


int main(){
	int n;
	cin >> n;
	pq_ip pq;
	for(int i=0; i<n; i++){
		int tmp;
		cin >> tmp;
		pq.push(make_pair(tmp, 0));
	}

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

	pq_ip copy_pq = pq;
	int result_min = n+1;
	for(int d=0; d<n; d++){
		int max_battle = 0;
		pq = copy_pq;
		for(int i=0; i<n; i++){
			int index = (i+d)%n;
			ip mons = pq.top();
			pq.pop();
			//cerr << "battle " << mons.first << "lv, count:" << mons.second << endl; 
			mons.first += enemy[index]/2;
			mons.second++;
			pq.push(mons);
			if(mons.second>max_battle){
				max_battle = mons.second;
			}
		}
		if(max_battle < result_min){
			result_min = max_battle;
		}
	}
	cout << result_min << endl;

	return 0;
}

0