#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << ": " << x << " "
#define nl cout << "\n"
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define per(i, a, b) for(int i = (a); i >= (b); i--)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long find_shortcut(int N, vector<int> l, vector<int> p, int C){
vector<ll> L(N), P(N);
rep(i, 0, N - 1){
if(i) L[i] = L[i - 1] + l[i - 1];
P[i] = p[i];
}
auto dist = [&](int i, int j, int l, int r){
ll ans = P[i] + P[j] + min({L[j] - L[i], abs(L[j] - L[r]) + C + abs(L[l] - L[i]), abs(L[j] - L[l]) + C + abs(L[r] - L[i])});
return ans;
};
auto diameter = [&](int l, int r){
ll ans = 0;
rep(i, 0, N - 1){
rep(j, i, N - 1){
ans = max(ans, dist(i, j, l, r));
}
}
return ans;
};
ll ans = LLONG_MAX;
rep(i, 0, N - 1){
rep(j, i, N - 1){
ans = min(ans, diameter(i, j));
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
204 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
204 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
1 ms |
204 KB |
n = 3, 4 is a correct answer |
5 |
Incorrect |
1 ms |
204 KB |
n = 2, incorrect answer: jury 62 vs contestant 72 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
204 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
204 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
1 ms |
204 KB |
n = 3, 4 is a correct answer |
5 |
Incorrect |
1 ms |
204 KB |
n = 2, incorrect answer: jury 62 vs contestant 72 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
204 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
204 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
1 ms |
204 KB |
n = 3, 4 is a correct answer |
5 |
Incorrect |
1 ms |
204 KB |
n = 2, incorrect answer: jury 62 vs contestant 72 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
204 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
204 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
1 ms |
204 KB |
n = 3, 4 is a correct answer |
5 |
Incorrect |
1 ms |
204 KB |
n = 2, incorrect answer: jury 62 vs contestant 72 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
204 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
204 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
1 ms |
204 KB |
n = 3, 4 is a correct answer |
5 |
Incorrect |
1 ms |
204 KB |
n = 2, incorrect answer: jury 62 vs contestant 72 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
204 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
204 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
1 ms |
204 KB |
n = 3, 4 is a correct answer |
5 |
Incorrect |
1 ms |
204 KB |
n = 2, incorrect answer: jury 62 vs contestant 72 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
204 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
204 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
1 ms |
204 KB |
n = 3, 4 is a correct answer |
5 |
Incorrect |
1 ms |
204 KB |
n = 2, incorrect answer: jury 62 vs contestant 72 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
204 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
204 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
1 ms |
204 KB |
n = 3, 4 is a correct answer |
5 |
Incorrect |
1 ms |
204 KB |
n = 2, incorrect answer: jury 62 vs contestant 72 |
6 |
Halted |
0 ms |
0 KB |
- |