結果

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

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 1 ms
3,540 KB
testcase_01 AC 1 ms
3,520 KB
testcase_02 AC 1,886 ms
3,564 KB
testcase_03 AC 1,309 ms
3,408 KB
testcase_04 AC 547 ms
3,456 KB
testcase_05 AC 303 ms
3,464 KB
testcase_06 AC 67 ms
3,468 KB
testcase_07 AC 2 ms
3,556 KB
testcase_08 AC 107 ms
3,524 KB
testcase_09 AC 1,753 ms
3,568 KB
testcase_10 AC 1 ms
3,392 KB
testcase_11 AC 3,379 ms
3,568 KB
testcase_12 AC 29 ms
3,472 KB
testcase_13 TLE -
testcase_14 AC 1,757 ms
3,564 KB
testcase_15 AC 1,585 ms
3,552 KB
testcase_16 AC 7 ms
3,548 KB
testcase_17 AC 833 ms
3,552 KB
testcase_18 AC 659 ms
3,408 KB
testcase_19 AC 4 ms
3,456 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