Submission #952080

#TimeUsernameProblemLanguageResultExecution timeMemory
952080MatjazTravelling Merchant (APIO17_merchant)C++14
0 / 100
42 ms2484 KiB
// // 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...