結果

問題 No.9 モンスターのレベル上げ
ユーザー femto
提出日時 2016-09-22 20:58:42
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 443 ms / 5,000 ms
コード長 914 bytes
コンパイル時間 904 ms
コンパイル使用メモリ 96,592 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-23 23:44:11
合計ジャッジ時間 5,433 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <functional>
#include <queue>
using namespace std;
typedef pair<int, int> Pii;

int A[1500];
int B[1500];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;
	for(int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for(int i = 0; i < N; i++) {
		cin >> B[i];
	}

	int ans = 1 << 25;
	for(int s = 0; s < N; s++) {
		priority_queue < Pii, vector<Pii>, greater<Pii> > q;
		for(int i = 0; i < N; i++) {
			q.push(Pii(A[i], 0));
		}

		int m = s;
		for(int i = 0; i < N; i++) {
			Pii p = q.top();
			q.pop();
			p.first += B[m] / 2;
			p.second++;
			q.push(p);
			m = (m + 1) % N;
		}
		int max_c = 0;
		for(int i = 0; i < N; i++) {
			max_c = max(max_c, q.top().second);
			q.pop();
		}
		ans = min(ans, max_c);
	}

	cout << ans << endl;
}
0