結果

問題 No.9 モンスターのレベル上げ
ユーザー ytft
提出日時 2022-11-02 17:13:46
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3,491 ms / 5,000 ms
コード長 736 bytes
コンパイル時間 3,198 ms
コンパイル使用メモリ 255,932 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-17 06:21:52
合計ジャッジ時間 25,766 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
	auto compare=[](vector<int> a,vector<int> b){
		if(a[0]!=b[0]){
			return a[0]>b[0];
		}else{
			return a[1]>b[1];
		}
	};
	int N;
	scanf("%d",&N);
	int A[N],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 ans=N;
	for(int i=0;i<N;++i){
		priority_queue<vector<int>,vector<vector<int>>,decltype(compare)>q {compare};
		int cand=0;
		for(int j=0;j<N;++j){
			q.push((vector<int>){A[j],0});
		}
		for(int j=0;j<N;++j){
			vector<int> temp=q.top();
			q.pop();
			temp[0]+=B[(i+j)%N]/2;
			++temp[1];
			if(cand<temp[1]){
				cand=temp[1];
			}
			q.push(temp);
		}
		if(ans>cand){
			ans=cand;
		}
	}
	printf("%d\n",ans);
}
0