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<iostream>
#include<vector>
#include<queue>
using namespace std;
typedef long long int lld;
#define INF 1000000000000000000
int main(){
int n,m,k;
cin>>n>>m>>k;
lld dist[n][n];
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
dist[i][j]=INF;
}dist[i][i]=0;
}
pair<lld,lld> table[n][k];
for(int i=0;i<n;i++){
for(int j=0;j<k;j++){
cin>>table[i][j].first>>table[i][j].second;
}
}
for(int i=0;i<m;i++){
int x,y;
cin>>x>>y;
x--;y--;
lld z;
cin>>z;
dist[x][y]=z;
}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
for(int k=0;k<n;k++){
dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
}
}
}
/*for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
cout<<dist[i][j]<<" ";
}cout<<endl;
}*/
lld ans=1;
for(int i=1;i<n;i++){
for(int j=0;j<k;j++){
if(table[i][j].second!=-1 && table[0][j].first!=-1){
ans=max(ans,(table[i][j].second-table[0][j].first)/(dist[i][0]+dist[0][i]));
//cout<<ans<<" "<<i<<" "<<j<<endl;
}
}
}
cout<<ans<<endl;
return 0;
}
# | 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... |