This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 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... |