# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
276945 | luciocf | 여행하는 상인 (APIO17_merchant) | C++14 | 30 ms | 1536 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
const int maxn = 110;
const int maxk = 1e3+10;
const ll inf = 1e18+10;
bool menor(pii a, pii b)
{
return a.ff*b.ss < b.ff*a.ss;
}
ll dist[maxn][maxn];
int b[maxn][maxk], s[maxn][maxk];
int main(void)
{
int n, m, k;
scanf("%d %d %d", &n, &m, &k);
for (int i = 1; i <= n; i++)
for (int j = 1; j <= k; j++)
scanf("%d %d", &b[i][j], &s[i][j]);
for (int i = 1; i <= n; i++)
for (int j = i+1; j <= n; j++)
dist[i][j] = dist[j][i] = inf;
for (int i = 1; i <= m; i++)
{
int u, v, w;
scanf("%d %d %d", &u, &v, &w);
dist[u][v] = min(dist[u][v], 1ll*w);
}
for (int l = 1; l <= n; l++)
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
dist[i][j] = min(dist[i][j], dist[i][l]+dist[l][j]);
pii ans = {0, 1};
for (int i = 2; i <= n; i++)
{
if (dist[1][i] == inf || dist[i][1] == inf) continue;
int q = dist[1][i]+dist[i][1];
int p = 0;
for (int j = 1; j <= k; j++)
if (b[1][j] != -1 && s[i][j] != -1)
p = max(p, s[i][j]-b[1][j]);
pii aux = {p/__gcd(p, q), q/__gcd(p, q)};
if (p > 0 && q > 0 && menor(aux, ans)) ans = aux;
}
printf("%lld\n", ans.ff/ans.ss);
}
컴파일 시 표준 에러 (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... |