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;
vector<vector<pair<int,int>>> items;
vector<vector<pair<int,int>>> lst;
vector<int> visited;
vector<pair<vector<int>,int>> ans;
vector<vector<int>> dist;
int n;
void fw(){
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]);
}
}
}
}
main(){
int m,k,v,w,t;
cin >> n >> m >> k;
// items --> vector[market][item][0-->buy / 1-->sell]
items = vector<vector<pair<int,int>>>(n,vector<pair<int,int>>(k));
dist = vector<vector<int>>(n,vector<int>(n,1e9));
for(int i=0;i<n;i++) dist[i][i]=0;
for(int i=0;i<n;i++){
for(int j=0;j<k;j++){
cin >> items[i][j].first >> items[i][j].second;
}
}
for(int i=0;i<m;i++){
cin >> v >> w >> t;
dist[v-1][w-1]=min(dist[v-1][w-1],t);
}
// busco cíclos
fw();
int res = 0;
for(int j=0;j<k;j++){
if(items[0][j].first==-1) continue;
for(int i=1;i<n;i++){
if(items[i][j].second==-1) continue;
res = max(res, (items[i][j].second-items[0][j].first)/(dist[0][i]+dist[i][0]));
}
}
cout << res << endl;
}
Compilation message (stderr)
merchant.cpp:22:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
22 | main(){
| ^~~~
# | 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... |