結果

問題 No.484 収穫
ユーザー olpheolphe
提出日時 2017-02-10 23:37:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,992 bytes
コンパイル時間 821 ms
コンパイル使用メモリ 88,536 KB
実行使用メモリ 8,768 KB
最終ジャッジ日時 2023-08-28 09:22:38
合計ジャッジ時間 6,852 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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];
bool fflag[2001];
long long int ff;
long long int ans=LLONG_MAX;
long long int box;
long long int bag;
long long int current;
priority_queue<long long int, vector<long long int>, greater<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;
			fflag[j] = true;
		}
		fflag[2000] = true;
		dis[i] = num[i];
		Q.push((dis[i] * (long long int)1e4 + i)*(long long int)1e4+2000);
		box = 0;
		while (!Q.empty()&&box<N) {
			if (flag[(Q.top() % (long long int)1e8)/(long long int)1e4]&&fflag[(Q.top()%(long long int)1e4)]) {
				current = Q.top();
				dis[(current % (long long int)1e8)/(long long int)1e4] = current / (long long int)1e8;
				//cout << current/(long long int)1e4 << endl;
				Q.pop();
				box++;
				flag[(current % (long long int)1e8)/(long long int)1e4] = false;
				fflag[current % 10000] = false;
				for (int j = 0; j < N; j++) {
					if (i != j) {
						if (max(dis[(current % (long long int)1e8)/(long long int)1e4] + abs(j - (current % (long long int)1e8)/(long long int)1e4), num[j]) < dis[j]) {
							Q.push(max(dis[(current % (long long int)1e8) / (long long int)1e4] + abs(j - (current % (long long int)1e8) / (long long int)1e4), num[j]) * (long long int)1e8 + j * (long long int)1e4 + (current % (long long int)1e8) / (long long int)1e4);
						}
					}
				}
			}
			else {
				Q.pop();
			}
		}
		bag = 0;
		for (int j = 0; j < N; j++) {
			bag = max(bag, dis[j]);
			//cout << dis[j] << endl;
		}
		ans = min(ans, bag);
	}
	cout << ans << endl;
	return 0;
}
0