Submission #403337

#TimeUsernameProblemLanguageResultExecution timeMemory
403337wiwihoTravelling Merchant (APIO17_merchant)C++14
12 / 100
23 ms1996 KiB
#include <bits/stdc++.h> #define mp make_pair #define F first #define S second #define printv(a, b) { \ for(auto pv : a) b << pv << " "; \ b << "\n"; \ } using namespace std; typedef long long ll; using pii = pair<int, int>; const ll MAX = 1LL << 60; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n, m, K; cin >> n >> m >> K; vector<vector<ll>> buy(n + 1, vector<ll>(K + 1)); vector<vector<ll>> sell(n + 1, vector<ll>(K + 1)); for(int i = 1; i <= n; i++){ for(int j = 1; j <= K; j++){ cin >> buy[i][j] >> sell[i][j]; if(i != 1) assert(buy[i][j] == -1); } } vector<vector<ll>> g(n + 1, vector<ll>(n + 1, MAX)); for(int i = 0; i < m; i++){ int u, v, w; cin >> u >> v >> w; g[u][v] = w; } for(int k = 1; k <= n; k++){ for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++){ g[i][j] = min(g[i][j], g[i][k] + g[k][j]); } } } //for(int i = 1; i <= n; i++) printv(g[i], cerr); ll ans = 0; for(int i = 2; i <= n; i++){ for(int j = 1; j <= K; j++){ if(buy[1][j] == -1 || sell[i][j] == -1) continue; ans = max(ans, (sell[i][j] - buy[1][j]) / (g[1][i] + g[i][1])); } } cout << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...