結果

問題 No.9 モンスターのレベル上げ
ユーザー shisyamokongarishisyamokongari
提出日時 2016-08-25 03:28:58
言語 C++11
(gcc 11.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 866 bytes
コンパイル時間 538 ms
コンパイル使用メモリ 62,516 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-06 04:57:58
合計ジャッジ時間 21,046 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1,899 ms
4,380 KB
testcase_03 AC 1,320 ms
4,376 KB
testcase_04 AC 552 ms
4,376 KB
testcase_05 AC 306 ms
4,376 KB
testcase_06 AC 68 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 109 ms
4,380 KB
testcase_09 AC 1,766 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 3,390 ms
4,376 KB
testcase_12 AC 31 ms
4,380 KB
testcase_13 TLE -
testcase_14 AC 1,773 ms
4,376 KB
testcase_15 AC 1,595 ms
4,380 KB
testcase_16 AC 7 ms
4,380 KB
testcase_17 AC 840 ms
4,376 KB
testcase_18 AC 663 ms
4,380 KB
testcase_19 AC 5 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>

using namespace std;

#define NMAX 1500

typedef struct s{
	int A,cnt;
} S;

bool operator<(S a,S b){
	return a.A<b.A||(a.A==b.A&&a.cnt<b.cnt);
}

int main(){

	int N;
	S A[NMAX],Atmp[NMAX];
	int B[NMAX];
	int ans;

	cin>>N;
	for(int i=0;i<N;i++){
		cin>>A[i].A;
		A[i].cnt=0;
		Atmp[i]=A[i];

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

	ans=N+1;

	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++) A[j]=Atmp[j];
		int j=i;
		bool f=false;
		sort(A,A+N);
		while(j!=i||!f){
			f=true;
			A[0].A+=(B[j]/2);
			A[0].cnt++;
			j++;
			if(N==j) j=0;
			S tmp=A[0];
			for(int k=1;;k++){
				if(k==N||A[k].A>tmp.A||(A[k].A==tmp.A&&A[k].cnt>tmp.cnt)){
					A[k-1]=tmp;
					break;
				}
				A[k-1]=A[k];

			}
		}
		int maxf=-1;
		for(int k=0;k<N;k++){
			if(A[k].cnt>maxf) maxf=A[k].cnt;
		}
		if(ans>maxf) ans=maxf;
	}

	cout<<ans<<endl;
}

0