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>
using namespace std;
using ll = long long;
ll di[105][105], b[105][1005], s[105][1005];
const ll inf = 1e18;
int main () {
ios::sync_with_stdio(false);
cin.tie(0);
int n, m, k;
cin >> n >> m >> k;
for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) di[i][j] = inf;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= k; j++) {
cin >> b[i][j];
if (b[i][j] == -1) b[i][j] = inf;
}
for (int j = 1; j <= k; j++) {
cin >> s[i][j];
if (s[i][j] == -1) s[i][j] = -inf;
}
}
while (m--) {
int u, v;
ll t;
cin >> u >> v >> t;
di[u][v] = min(di[u][v], t);
}
for (int t = 1; t <= n; t++) for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) di[i][j] = min(di[i][j], di[i][t] + di[t][j]);
ll ans = 0;
for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) for (int t = 1; t <= k; t++) ans = max(ans, (s[j][t] - b[i][t]) / (di[i][j] + di[j][i]));
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... |