結果

問題 No.9 モンスターのレベル上げ
ユーザー cielciel
提出日時 2015-04-17 23:37:47
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 255 ms / 5,000 ms
コード長 640 bytes
コンパイル時間 430 ms
コンパイル使用メモリ 54,504 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-06 03:44:11
合計ジャッジ時間 3,530 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 255 ms
4,376 KB
testcase_03 AC 204 ms
4,380 KB
testcase_04 AC 106 ms
4,380 KB
testcase_05 AC 69 ms
4,376 KB
testcase_06 AC 24 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 31 ms
4,376 KB
testcase_09 AC 248 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 200 ms
4,376 KB
testcase_12 AC 160 ms
4,376 KB
testcase_13 AC 143 ms
4,376 KB
testcase_14 AC 252 ms
4,380 KB
testcase_15 AC 232 ms
4,380 KB
testcase_16 AC 5 ms
4,380 KB
testcase_17 AC 145 ms
4,376 KB
testcase_18 AC 123 ms
4,380 KB
testcase_19 AC 4 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <queue>
#include <algorithm>
#include <cstdio>
using namespace std;
typedef pair<int,int> pii;
int perform(vector<int>&a,vector<int>&b){
	priority_queue<pii,vector<pii>,greater<pii> >q;
	for(auto &e:a)q.push({e,0});
	int ret=0;
	for(auto &e:b){
		pii cur=q.top();
		q.pop();
		cur.first+=e/2;
		ret=max(ret,++cur.second);
		q.push(cur);
	}
	return ret;
}

int main(){
	int N;
	scanf("%d",&N);
	vector<int>a(N);
	vector<int>b(N);
	for(int i=0;i<N;i++)scanf("%d",&a[i]);
	for(int i=0;i<N;i++)scanf("%d",&b[i]);
	int r=N;
	for(int i=0;i<N;i++){
		rotate(b.begin(),b.begin()+1,b.end());
		r=min(r,perform(a,b));
	}
	printf("%d\n",r);
}
0