# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1160546 | jus_teng | Travelling Merchant (APIO17_merchant) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double ld;
const ll maxN = 100;
const ll maxK = 1000;
const ld inf = 1e18;
const ld eps = 1e-9;
ll n, m, k;
vector<vector<pair<ll, ll>>> adj;
vector<vector<ll>> b, s;
bool check(ld lambda) {
ll v = n * (k + 1);
vector<ld> dist(v, -inf);
// Initialize starting states (no item at each market)
for (ll u = 0; u < n; u++) {
dist[u * (k + 1)] = 0; // No item state
}
// Bellman-Ford: V-1 relaxations
for (ll iter = 0; iter < v - 1; iter++) {
bool updated = false;
for (ll u = 0; u < n; u++) {
ll uNoItem = u * (k + 1);
// Buy an item