Submission #952086

#TimeUsernameProblemLanguageResultExecution timeMemory
952086MatjazTravelling Merchant (APIO17_merchant)C++14
12 / 100
44 ms1112 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; long long INF = (1LL<<39); 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<long long> > dist(N, vector<long long>(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]); } } long long best = 0; for (int i=1;i<N;i++){ int max_profit = 0; for (int j=0;j<K;j++) if (B[0][j] < 0) continue; else 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...