이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("Ofast", "unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
using pii = pair<int, int>;
template<typename T>
using prior = std::priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = std::priority_queue<T>;
#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back
#define fastIO() ios_base::sync_with_stdio(false), cin.tie(0)
const int INF = 0x7f7f7f7f;
const int maxn = 100 + 5;
const int maxk = 1000 + 5;
int bs[2][maxn][maxk];
int floyd[maxn][maxn];
int32_t main() {
fastIO();
int n, m, k;
cin >> n >> m >> k;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= k; ++j) {
cin >> bs[0][i][j] >> bs[1][i][j];
}
}
memset(floyd, 0x3f, sizeof(floyd));
for (int i = 0; i < m; ++i) {
int u, v, w;
cin >> u >> v >> w;
floyd[u][v] = min(floyd[u][v], w);
}
for (int tr = 1; tr <= n; ++tr) {
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) {
floyd[i][j] = min(floyd[i][j], floyd[i][tr] + floyd[tr][j]);
}
}
}
int ans = 0;
for (int i = 1; i <= n; ++i) {
int maxProf = 0;
for (int j = 1; j <= k; ++j) {
if (bs[0][1][j] != -1) {
// cerr << "owo " << bs[1][i][j] << " " << bs[1][i][j] - bs[0][1][j] << "\n";
maxProf = max(maxProf, bs[1][i][j] - bs[0][1][j]);
}
}
// cerr << floyd[1][i] << " " << floyd[i][1] << "\n";
if (i == 1) maxProf /= floyd[1][1];
else maxProf /= floyd[1][i] + floyd[i][1];
ans = max(ans, maxProf);
}
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... |