結果

問題 No.9 モンスターのレベル上げ
ユーザー shisyamokongarishisyamokongari
提出日時 2016-08-25 02:26:37
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 780 bytes
コンパイル時間 499 ms
コンパイル使用メモリ 62,164 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-08-07 20:50:34
合計ジャッジ時間 7,146 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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;
		while(j!=i||!f){
			f=true;
			sort(A,A+N);
			A[0].A+=B[j];
			A[0].cnt++;
			j++;
			if(N==j) j=0;
		}
		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