#include "shortcut.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1005;
int n;
ll c;
ll w[N],d[N];
ll dp[N][N];
ll ans=1e18;
ll calc(int x,int y){
for(int i=1;i<=2*n;i++)for(int j=1;j<=2*n;j++)dp[i][j]=1e18;
for(int i=1;i<n;i++)dp[i][i+1]=dp[i+1][i]=w[i];
for(int i=1;i<=n;i++)dp[i][n+i]=dp[n+i][i]=d[i];
dp[x][y]=dp[y][x]=min(dp[x][y],c);
for(int k=1;k<=2*n;k++)for(int i=1;i<=2*n;i++)for(int j=1;j<=2*n;j++)dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
ll res=0;
for(int i=1;i<=2*n;i++)for(int j=1;j<=2*n;j++)res=max(res,dp[i][j]);
return res;
}
long long find_shortcut(int _n, vector<int> _w, vector<int> _d, int _c){
n=_n,c=_c;
for(int i=0;i<n-1;i++)w[i+1]=_w[i];
for(int i=0;i<n;i++)d[i+1]=_d[i];
for(int i=1;i<=n;i++){
for(int j=i+1;j<=n;j++){
ans=min(ans,calc(i,j));
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
340 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
340 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Incorrect |
1 ms |
212 KB |
n = 2, incorrect answer: jury 62 vs contestant 72 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
340 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
340 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Incorrect |
1 ms |
212 KB |
n = 2, incorrect answer: jury 62 vs contestant 72 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
340 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
340 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Incorrect |
1 ms |
212 KB |
n = 2, incorrect answer: jury 62 vs contestant 72 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
340 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
340 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Incorrect |
1 ms |
212 KB |
n = 2, incorrect answer: jury 62 vs contestant 72 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
340 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
340 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Incorrect |
1 ms |
212 KB |
n = 2, incorrect answer: jury 62 vs contestant 72 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
340 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
340 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Incorrect |
1 ms |
212 KB |
n = 2, incorrect answer: jury 62 vs contestant 72 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
340 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
340 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Incorrect |
1 ms |
212 KB |
n = 2, incorrect answer: jury 62 vs contestant 72 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
340 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
340 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Incorrect |
1 ms |
212 KB |
n = 2, incorrect answer: jury 62 vs contestant 72 |
6 |
Halted |
0 ms |
0 KB |
- |