This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//
// APIO17_MERCHANT.cpp
//
//
// Created by Matjaz Leonardis on 22/03/2024.
//
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int N,M,K;
int INF = (1<<29);
int main(){
cin >> N >> M >> K;
vector<vector<int> > B(N, vector<int> (K));
vector<vector<int> > S(N, vector<int> (K));
for (int i=0;i<N;i++){
for (int j=0;j<K;j++) cin >> B[i][j] >> S[i][j];
}
vector<vector<int> > dist(N, vector<int>(N, INF));
for (int i=0;i<M;i++){
int V,W,T;
cin >> V >> W >> T;
dist[V - 1][W - 1] = T;
}
for (int k=0;k<N;k++){
for (int i=0;i<N;i++){
for (int j=0;j<N;j++) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
}
}
int best = 0;
for (int i=1;i<N;i++){
int max_profit = 0;
for (int j=0;j<K;j++) max_profit = max(max_profit, S[i][j] - B[0][j]);
best = max(best, max_profit / (dist[0][i] + dist[i][0]));
}
cout << best << endl;
return 0;
}
/*vector<vector<pair<int,int> > > s(N, vector<pair<int,int> > ());
for (int i=0;i<M;i++){
int V,W,T;
cin >> V >> W >> T;
s[V - 1].push_back(make_pair(W - 1, T));
} */
# | 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... |