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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#ifdef ONPC
#include "t_debug.cpp"
#else
#define debug(...) 42
#endif
#define allit(a) (a).begin(), (a).end()
#define sz(a) ((int) (a).size())
#define cut(s) {cout << s << '\n'; return 0;}
using namespace std;
using ll = long long;
using vi = vector<int>;
namespace pd = __gnu_pbds;
template<typename K> using ordered_set = pd::tree<K, pd::null_type, less<K>, pd::rb_tree_tag, pd::tree_order_statistics_node_update>;
template<typename... T> using hash_table = pd::gp_hash_table<T...>;
const int INF = 1e9;
const ll INFL = 1e18;
const int N = 1e5;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(RANDOM);
int solve() {
int n, m, k;
cin >> n >> m >> k;
int buy[n][k];
int sell[n][k];
for (int i = 0; i < n; i++) {
for (int j = 0; j < k; j++) {
cin >> buy[i][j];
cin >> sell[i][j];
}
}
int adj[n][n];
int dist[n][n];
memset(adj, 0, sizeof(adj));
memset(dist, 0x3d, sizeof(dist));
for (int i = 0; i < m; i++) {
int u, v, w;
cin >> u >> v >> w;
adj[u-1][v-1] = w;
dist[u-1][v-1] = w;
}
for (int k = 0; k < n; k++)
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
int res = 0;
for (int j = 1; j < n; j++) {
debug(dist[0][j], dist[j][0]);
if (dist[0][j] + dist[j][0] > INF) continue;
int mxDiff = 0;
for (int item = 0; item < k; item++) {
mxDiff = max(mxDiff, sell[j][item] - buy[0][item]);
}
int efficiency = mxDiff / (dist[0][j]+dist[j][0]);
debug(j, mxDiff, efficiency);
res = max(res, efficiency);
}
cout << res << '\n';
return 0;
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
int t = 1;
//cin >> t;
while (t-- && cin) {
if (solve()) break;
#ifdef ONPC
cout << "____________________" << endl;
#endif
}
return 0;
}
Compilation message (stderr)
merchant.cpp: In function 'int solve()':
merchant.cpp:7:24: warning: statement has no effect [-Wunused-value]
7 | #define debug(...) 42
| ^~
merchant.cpp:55:9: note: in expansion of macro 'debug'
55 | debug(dist[0][j], dist[j][0]);
| ^~~~~
merchant.cpp:7:24: warning: statement has no effect [-Wunused-value]
7 | #define debug(...) 42
| ^~
merchant.cpp:62:9: note: in expansion of macro 'debug'
62 | debug(j, mxDiff, efficiency);
| ^~~~~
# | 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... |