結果

問題 No.9 モンスターのレベル上げ
ユーザー shisyamokongarishisyamokongari
提出日時 2016-08-25 02:37:07
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 990 bytes
コンパイル時間 644 ms
コンパイル使用メモリ 60,144 KB
実行使用メモリ 14,016 KB
最終ジャッジ日時 2024-04-25 15:14:18
合計ジャッジ時間 7,088 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
9,888 KB
testcase_01 AC 2 ms
6,944 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;
		int t=0;
		while(j!=i||!f){
			f=true;
			if(t==0){
				sort(A,A+N);
				A[0].A+=B[j];
				A[0].cnt++;
			}
			else{
				if(A[0].A<A[1].A||(A[0].A==A[1].A&&A[0].cnt<A[1].cnt)){
					A[0].A+=B[j];
					A[0].cnt++;
				}
				else{
					A[1].A+=B[j];
					A[1].cnt++;
				}
			}
			t=1-t;
			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