結果

問題 No.484 収穫
ユーザー olpheolphe
提出日時 2017-02-10 23:13:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,273 bytes
コンパイル時間 2,899 ms
コンパイル使用メモリ 87,528 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-28 08:47:41
合計ジャッジ時間 2,220 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "map"

using namespace std;
const long long int MOD = 1000000007;

typedef pair<int, int> P;
int N;
long long int num[2000];
long long int dis[2000];
bool flag[2000];
long long int ans=LLONG_MAX;
long long int box;
long long int bag;
long long int current;
priority_queue<long long int>Q;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> num[i];
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			dis[j] = LLONG_MAX;
			flag[j] = true;
		}
		dis[i] = num[i];
		Q.push(dis[i] * 10000 + i);
		while (!Q.empty()&&box<N) {
			if (flag[Q.top() % 10000]) {
				current = Q.top();
				Q.pop();
				box++;
				flag[current % 10000] = false;
				for (int j = 0; j < N; j++) {
					if (i != j) {
						if (max(dis[current % 10000] + abs(j - i), num[j]) < dis[j]) {
							dis[j] = max(dis[current % 10000] + abs(j - i), num[j]);
							Q.push(dis[j] * 10000 + j);
						}
					}
				}
			}
			else {
				Q.pop();
			}
		}
		bag = 0;
		for (int j = 0; j < N; j++) {
			bag = max(bag, dis[j]);
		}
		ans = min(ans, bag);
	}
	cout << ans << endl;
	return 0;
}
0