結果

問題 No.9 モンスターのレベル上げ
ユーザー 158b158b
提出日時 2015-05-14 19:53:51
言語 C++11
(gcc 8.5.0)
結果
AC  
実行時間 1,889 ms / 5,000 ms
コード長 1,450 bytes
コンパイル時間 435 ms
使用メモリ 3,580 KB
最終ジャッジ日時 2023-01-21 14:30:20
合計ジャッジ時間 10,413 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 1 ms
3,504 KB
testcase_01 AC 1 ms
3,424 KB
testcase_02 AC 1,012 ms
3,396 KB
testcase_03 AC 697 ms
3,524 KB
testcase_04 AC 293 ms
3,448 KB
testcase_05 AC 163 ms
3,552 KB
testcase_06 AC 38 ms
3,448 KB
testcase_07 AC 2 ms
3,480 KB
testcase_08 AC 59 ms
3,540 KB
testcase_09 AC 938 ms
3,404 KB
testcase_10 AC 1 ms
3,476 KB
testcase_11 AC 1,889 ms
3,580 KB
testcase_12 AC 13 ms
3,404 KB
testcase_13 AC 1,102 ms
3,576 KB
testcase_14 AC 942 ms
3,468 KB
testcase_15 AC 849 ms
3,504 KB
testcase_16 AC 5 ms
3,536 KB
testcase_17 AC 446 ms
3,520 KB
testcase_18 AC 352 ms
3,508 KB
testcase_19 AC 3 ms
3,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
using namespace std;

const int Max_monster = 1500;
const int Max_lv = 100000;
const int Max_ans = 30;

long save[Max_monster];	//l
long my[Max_monster];	//l
long com[Max_monster];

//もっと単純に!
//save,my体裁 lv*10000+戦闘回数
int main(){
	int n;
	long in;
	long ans = LONG_MAX;
	long ansmax;
	int i,j;
	long swap;	//l
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> in;
		save[i] = in * 10000;
	}
	
	for(int i=0; i<n; i++){
		cin >> com[i];
	}
	
	//ソート関数にてソート
	sort(save, save+n);
	
	//計算部分
	for(int starti=0; starti<n; starti++){
		//cout << "-----" << starti << "-----" << endl;
		//my表作成
		for(int i=0; i<n; i++){
			my[i] = save[i];
		}
		
		//戦闘
		i=starti;
		do{
			//battle
			my[0] += com[i] / 2 * 10000 + 1;
			
			//my[0]だけ移動
			
			swap = my[0];
			j = 1;
			while(j < n && swap > my[j]){
				my[j-1] = my[j];
				j ++;
			}
			my[j-1] = swap;
			
			//cout << "戦闘" << ansnow << "→" << ansnow+1 << "\tLV" << lvnow << "→" << lvnow + com[i]/2 << endl;
			
			//next
			i ++;
			if(i >= n){
				i=0;
			}
		}while(i != starti);
		
		//最高戦闘回数チェックとans更新
		ansmax = -1;
		for(int i=0; i<n; i++){
			if(my[i] % 10000 > ansmax){
				ansmax = my[i] % 10000;
			}
		}
		
		if(ansmax < ans){
			ans = ansmax;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}
0