#include <bits/stdc++.h>
/// #pragma GCC optimize ("Ofast")
/// #pragma GCC target ("avx2")
/// #pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using ld = long double;
using ii = pair<ll, ll>;
using vi = vector<int>;
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lb lower_bound
void solve(int N, vector<int> e, vector<int> d, int c, int S, int i, int j, vector<ll>& D) {
priority_queue<pair<ll, int>,
vector<pair<ll, int>>, greater<pair<ll, int>>> pq;
pq.push({d[S], S}); D.assign(N, 1000000000000000007); D[S] = d[S];
while(!pq.empty()) {
ll A = pq.top().ss, W = pq.top().ff; pq.pop();
if(W > D[A]) continue;
int V = A + 1;
if(A < N - 1 && D[V] > D[A] + e[A]) {
D[V] = D[A] + e[A];
pq.push({D[V], V});
}
V = A - 1;
if(A > 0 && D[V] > D[A] + e[A - 1]) {
D[V] = D[A] + e[A - 1];
pq.push({D[V], V});
}
if(A == i && D[A] + c < D[j]) {
D[j] = D[A] + c;
pq.push({D[j], j});
}
if(A == j && D[A] + c < D[i]) {
D[i] = D[A] + c;
pq.push({D[i], i});
}
}
}
long long find_shortcut(int N, vector<int> e, vector<int> d, int c) {
ll best = 1000000000000000007;
for(int i = 0; i < N; i++) {
for(int j = i + 1; j < N; j++) {
vector<ll> D;
solve(N, e, d, c, 0, i, j, D);
int V = 0;
for(int k = 1; k < N; k++) D[k] += d[k];
for(int k = 0; k < N; k++) {
if(D[k] >= D[V]) V = k;
}
vector<int> u;
for(int k = 0; k < N; k++)
if(D[k] == D[V]) u.push_back(k);
V = u[(u.size()) / 2];
solve(N, e, d, c, V, i, j, D);
ll ans = 0;
for(int k = 0; k < N; k++) {
if(k == V) continue;
D[k] += d[k];
}
for(int k = 0; k < N; k++)
ans = max(ans, D[k]);
best = min(best, ans);
}
}
return best;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
1 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
1 ms |
212 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
1 ms |
212 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
1 ms |
212 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
1 ms |
212 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
212 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
1 ms |
212 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
212 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
0 ms |
212 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
0 ms |
212 KB |
n = 10, 3189 is a correct answer |
19 |
Incorrect |
1 ms |
212 KB |
n = 10, incorrect answer: jury 7000000000 vs contestant 6000000000 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
1 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
1 ms |
212 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
1 ms |
212 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
1 ms |
212 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
1 ms |
212 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
212 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
1 ms |
212 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
212 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
0 ms |
212 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
0 ms |
212 KB |
n = 10, 3189 is a correct answer |
19 |
Incorrect |
1 ms |
212 KB |
n = 10, incorrect answer: jury 7000000000 vs contestant 6000000000 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
1 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
1 ms |
212 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
1 ms |
212 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
1 ms |
212 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
1 ms |
212 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
212 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
1 ms |
212 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
212 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
0 ms |
212 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
0 ms |
212 KB |
n = 10, 3189 is a correct answer |
19 |
Incorrect |
1 ms |
212 KB |
n = 10, incorrect answer: jury 7000000000 vs contestant 6000000000 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
1 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
1 ms |
212 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
1 ms |
212 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
1 ms |
212 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
1 ms |
212 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
212 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
1 ms |
212 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
212 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
0 ms |
212 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
0 ms |
212 KB |
n = 10, 3189 is a correct answer |
19 |
Incorrect |
1 ms |
212 KB |
n = 10, incorrect answer: jury 7000000000 vs contestant 6000000000 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
1 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
1 ms |
212 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
1 ms |
212 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
1 ms |
212 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
1 ms |
212 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
212 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
1 ms |
212 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
212 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
0 ms |
212 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
0 ms |
212 KB |
n = 10, 3189 is a correct answer |
19 |
Incorrect |
1 ms |
212 KB |
n = 10, incorrect answer: jury 7000000000 vs contestant 6000000000 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
1 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
1 ms |
212 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
1 ms |
212 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
1 ms |
212 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
1 ms |
212 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
212 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
1 ms |
212 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
212 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
0 ms |
212 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
0 ms |
212 KB |
n = 10, 3189 is a correct answer |
19 |
Incorrect |
1 ms |
212 KB |
n = 10, incorrect answer: jury 7000000000 vs contestant 6000000000 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
1 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
1 ms |
212 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
1 ms |
212 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
1 ms |
212 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
1 ms |
212 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
212 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
1 ms |
212 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
212 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
0 ms |
212 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
0 ms |
212 KB |
n = 10, 3189 is a correct answer |
19 |
Incorrect |
1 ms |
212 KB |
n = 10, incorrect answer: jury 7000000000 vs contestant 6000000000 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
1 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
1 ms |
212 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
1 ms |
212 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
1 ms |
212 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
1 ms |
212 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
256 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
212 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
1 ms |
212 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
0 ms |
212 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
0 ms |
212 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
0 ms |
212 KB |
n = 10, 3189 is a correct answer |
19 |
Incorrect |
1 ms |
212 KB |
n = 10, incorrect answer: jury 7000000000 vs contestant 6000000000 |
20 |
Halted |
0 ms |
0 KB |
- |