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;
#define int long long
const int INF = 1e18;
const int MAX_N = 100;
const int MAX_K = 1000;
int N,M,K;
vector<vector<int>> adj(MAX_N,vector<int>(MAX_N,INF));
vector<vector<int>> B(MAX_N, vector<int>(MAX_K)), S(MAX_N, vector<int>(MAX_K));
main() {
cin >> N >> M >> K;
for (int i = 0; i < N; i++) {
for (int z = 0; z < K; z++) {
cin >> B[i][z] >> S[i][z];
}
}
for (int i = 0; i < M; i++) {
int V,W,P; cin >> V >> W >> P;
adj[V-1][W-1] = P;
}
auto dist = adj;
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 ans = 0;
for (int i = 1; i < N; i++) {
int val = 0;
for (int z = 0; z < K; z++) {
val = max(val,S[i][z] - B[0][z]);
}
ans = max(ans,val/(dist[0][i]+dist[i][0]));
}
cout << ans << "\n";
return 0;
}
Compilation message (stderr)
merchant.cpp:14:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main() {
^
# | 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... |