| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 454565 | sean617 | 여행하는 상인 (APIO17_merchant) | C++98 | 505 ms | 4168 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <cstdio>
#include <vector>
#define N 105
using namespace std;
typedef long long ll;
ll n, m, k, tc, M = 1e16, mx, B[N][1005], S[N][1005], di[N][N], ds[N], dt[N];
struct str {
ll z, c1, c2;
};
bool operator < (str p, str q) {
return p.c1 * q.c2 < q.c1 * p.c2;
}
vector<str> a;
int main()
{
ll i, j, t1, t2, t3, kk, us, ut;
str t;
cin >> n >> m >> k;
for (i = 1; i <= n; i++) {
for (j = 1; j <= k; j++) {
scanf ("%lld %lld", &B[i][j], &S[i][j]);
}
}
for (i = 1; i <= n; i++) {
for (j = 1; j <= n; j++) {
di[i][j] = M;
}
}
for (i = 0; i < m; i++) {
scanf ("%lld %lld %lld", &t1, &t2, &t3);
di[t1][t2] = min(di[t1][t2], t3);
}
for (kk = 1; kk <= n; kk++) {
for (i = 1; i <= n; i++) {
for (j = 1; j <= n; j++) {
di[i][j] = min(di[i][j], di[i][kk] +di[kk][j]);
}
}
}
for (i = 1; i <= n; i++) {
for (j = 1; j <= n; j++) {
if (di[i][j] == M || i == j) continue;
mx = -1;
for (kk = 1; kk <= k; kk++) {
if (B[i][kk] != -1 && S[j][kk] != -1 && S[j][kk] - B[i][kk] > 0) mx = max(mx, S[j][kk] - B[i][kk]);
}
a.push_back({i, j, (mx == -1 ? 0 : mx)});
}
}
mx = 0;
for (tc = 1; tc <= n; tc++) {
for (i = 1; i <= n; i++) {dt[i] = -1; ds[i] = -1;}
dt[tc] = 0; ds[tc] = 0;
for (j = 0; j <= n; j++) {
for (i = 0; i < a.size(); i++) {
t1 = a[i].z;
t2 = a[i].c1;
if (dt[t1] == -1) continue;
ut = dt[t1] + di[t1][t2];
us = ds[t1] + a[i].c2;
if (t2 == tc) mx = max(mx, us / ut);
else {
if (dt[t2] == -1 || us * dt[t2] > ut * ds[t2]) {ds[t2] = us; dt[t2] = ut;}
}
}
}
}
cout << mx << endl;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | 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... | ||||
