This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//khodaya khodet komak kon
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-O2")
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int N = 100 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000000000010;
const ll LOG = 25;
int n, m, k, B[N][N * 10], S[N][N * 10];
ll dis[N][N];
int32_t main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> m >> k;
for (int i = 1; i <= n; i++){
for (int j = 1; j <= 2 * k; j++){
if (j % 2 == 1) cin >> B[i][j / 2 + 1];
else cin >> S[i][j / 2];
}
}
for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) dis[i][j] = INF;
for (int i =1 ; i <= m; i++){
ll v, u, T;
cin >> v >> u >> T;
dis[v][u] = min(dis[v][u], T);
}
for (int k = 1; k <= n; k++)for (int v = 1; v <= n; v++) for (int u = 1; u <= n; u++) dis[v][u] = min(dis[v][u], dis[v][k] + dis[k][u]);
ll ans = 0;
for (int i = 1; i <= k; i++){
if (B[1][i] != -1){
for (int j = 2; j <= n; j++){
// cout << i << ' ' << j << ' ' << dis[1][j] << ' ' << dis[j][1] << '\n';
ans = max(ans, (S[j][i] - B[1][i]) / (dis[1][j] + dis[j][1]));
}
}
}
cout << ans;
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... |