# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
52092 | Angelos | Travelling Merchant (APIO17_merchant) | C11 | 0 ms | 0 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;
const int N = 105;
const int K = 1005;
const long long INF = 1e10;
const int MAX_ANS = 1e9 + 1;
int n, m, items;
int buy[N][K], sell[N][K];
long long dist[N][N], profit[N][N];
long long adj[N][N], adj2[N][N];
inline bool check(long long x) {
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
if (dist[i][j] == INF) {
adj[i][j] = -INF;
} else {
adj[i][j] = profit[i][j] - dist[i][j] * x;
adj[i][j] = max(-INF, adj[i][j]);
}
}
adj[i][i] = -INF;
}
long long res = -INF;
for (int k = 1; k <= n; k++) {
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
adj[i][j] = max(adj[i][j], adj[i][k] + adj[k][j]);