結果

問題 No.9 モンスターのレベル上げ
ユーザー shisyamokongarishisyamokongari
提出日時 2016-08-25 03:04:30
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 956 bytes
コンパイル時間 436 ms
コンパイル使用メモリ 61,804 KB
実行使用メモリ 4,512 KB
最終ジャッジ日時 2023-08-07 20:51:18
合計ジャッジ時間 26,829 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1 ms
4,380 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 4,738 ms
4,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

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];
	int B[NMAX];
	int ansx,ansn;

	cin>>N;
	for(int i=0;i<N;i++) cin>>A[i].A;
	for(int i=0;i<N;i++) cin>>B[i];
	ansx=-1;
	ansn=N+1;

	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++) A[j].cnt=0;
		int j=i;
		bool f=false;
		int t=0;
		sort(A,A+N);
		while(j!=i||!f){
			f=true;
			A[0].A+=B[j];
			A[0].cnt++;
			j++;
			t++;
			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;
		int minf=N+1;
		for(int k=0;k<N;k++){
			if(A[k].cnt>maxf) maxf=A[k].cnt;
			if(A[k].cnt<minf) minf=A[k].cnt;
		}
		if(ansn>minf) ansn=minf,ansx=maxf;
		else if(ansn==minf&&ansx<maxf) ansx=maxf;
	}

	cout<<ansx<<endl;
}

0