# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
540809 | LucaDantas | Travelling Merchant (APIO17_merchant) | C++17 | 29 ms | 1488 KiB |
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;
constexpr int maxn = 110, maxk = 1010, inf = 0x3f3f3f3f;
int valor[maxn][maxn]; // grafo completo final
int dp[maxn][maxn]; // floyd warshall
int b[maxn][maxk], s[maxn][maxk];
int main() {
int n, m, k; scanf("%d %d %d", &n, &m, &k);
memset(dp, 0x3f, sizeof dp);
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 = 0; i < m; i++) {
int a, b, w; scanf("%d %d %d", &a, &b, &w);
dp[a][b] = w;
}
for(int l = 1; l <= n; l++)
for(int i = 1; i <= n; i++)
for(int j = 1; j <= n; j++)
if(dp[i][l] < inf && dp[l][j] < inf)
dp[i][j] = min(dp[i][j], dp[i][l] + dp[l][j]);
for(int i = 1; i <= n; i++)
for(int j = 1; j <= n; j++)
for(int l = 1; l <= k; l++)
valor[i][j] = max(valor[i][j], -b[i][l] +s[j][l]); // compro 'l' em 'i' e vendo em 'j'
/* for(int i = 2; i <= n; i++)
printf("%d %d %d\n", valor[1][i], dp[1][i], dp[i][1]); */
int ans = 0;
for(int i = 2; i <= n; i++)
ans = max(ans, valor[1][i] / (dp[1][i] + dp[i][1]));
printf("%d\n", ans);
}
Compilation message (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... |