結果
| 問題 |
No.484 収穫
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-02-10 23:38:46 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,667 bytes |
| コンパイル時間 | 1,049 ms |
| コンパイル使用メモリ | 96,004 KB |
| 実行使用メモリ | 20,420 KB |
| 最終ジャッジ日時 | 2024-12-29 05:45:03 |
| 合計ジャッジ時間 | 52,146 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 TLE * 12 |
ソースコード
#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] * 10000 + i)*10000+2000);
box = 0;
while (!Q.empty()&&box<N) {
if (flag[(Q.top() % 100000000)/10000]&&fflag[(Q.top()%10000)]) {
current = Q.top();
dis[(current % 100000000)/10000] = current / 100000000;
Q.pop();
box++;
flag[(current % 100000000)/10000] = false;
fflag[current % 10000] = false;
for (int j = 0; j < N; j++) {
if (i != j) {
if (max(dis[(current % 100000000)/10000] + abs(j - (current % 100000000)/10000), num[j]) < dis[j]) {
Q.push(max(dis[(current % 100000000) / 10000] + abs(j - (current % 100000000) / 10000), num[j]) * 100000000 + j * 10000 + (current % 100000000) / 10000);
}
}
}
}
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;
}