This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,m,k;
int b[101][1001],s[101][1001];
int g[101][101],floyd[101][101];
signed main(){
cin>>n>>m>>k;
for (int i=1; i<=n; i++){
for (int j=1; j<=k; j++) cin>>b[i][j]>>s[i][j];
}
for (int i=1; i<=n; i++){
for (int j=1; j<=n; j++) g[i][j]=floyd[i][j]=1e18;
}
for (int i=0; i<m; i++){
int u,v,w;
cin>>u>>v>>w;
g[u][v]=min(g[u][v],w);
floyd[u][v]=min(floyd[u][v],w);
}
for (int l=1; l<=n; l++){
for (int i=1; i<=n; i++){
for (int j=1; j<=n; j++) floyd[i][j]=min(floyd[i][j],floyd[i][l]+floyd[l][j]);
}
}
int ans=0;
for (int i=1; i<=n; i++){
if (floyd[1][i]==1e18||floyd[i][1]==1e18) continue;
for (int j=1; j<=k; j++) ans=max(ans,(s[i][j]-b[1][j])/(floyd[1][i]+floyd[i][1]));
}
cout<<ans<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |