제출 #907643

#제출 시각아이디문제언어결과실행 시간메모리
907643vjudge1여행하는 상인 (APIO17_merchant)C++17
12 / 100
49 ms2072 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; #define int ll #define ii pair<int,int> const int N = 105; const int K = 1010; int buy[N][K]; int sell[N][K]; int n, m, k; vector<ii> adj[N]; int dis[N][N]; signed main(){ cin >> n >> m >> k; for(int i=0; i<n; ++i){ for(int j=0; j<k; ++j){ cin >> buy[i][j] >> sell[i][j]; } } for(int i=0; i<n; ++i){ for(int j=0; j<n; ++j){ dis[i][j] = 4e18; } dis[i][i] = 0; } for(int i=0; i<m; ++i){ int u, v, w; cin >> u >> v >> w; u--, v--; adj[u].push_back({v, w}); dis[u][v] = min(dis[u][v], w); } // floyd for(int p=0; p<n; ++p){ for(int u=0; u<n; ++u){ for(int v=0; v<n; ++v){ if(u == v) continue; dis[u][v] = min(dis[u][v], dis[u][p] + dis[p][v]); } } } int ans = 0; for(int i=0; i<k; ++i){ // suppose I'm buying the ith item if(buy[0][i] == -1) continue; for(int p=1; p<n; ++p){ if(sell[p][i] == -1) continue; // I sell it in market p int profit = sell[p][i] - buy[0][i]; profit /= dis[0][p] + dis[p][0]; ans = max(ans, profit); } } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...