# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
200323 | 2020-02-06T10:29:05 Z | BThero | Travelling Merchant (APIO17_merchant) | C++17 | 29 ms | 1272 KB |
// Why am I so dumb? :c // chrono::system_clock::now().time_since_epoch().count() #include<bits/stdc++.h> //#include<ext/pb_ds/assoc_container.hpp> //#include<ext/pb_ds/tree_policy.hpp> #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define fi first #define se second using namespace std; //using namespace __gnu_pbds; typedef long long ll; typedef pair<int, int> pii; //template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; const int MAXN = (int)1e2 + 5; const int MAXK = (int)1e3 + 5; const ll LINF = (ll)1e17; int buy[MAXN][MAXK], sell[MAXN][MAXK]; ll dp[MAXN][MAXN][MAXK]; int adj[MAXN][MAXN]; ll dist[MAXN][MAXN]; int n, m, k; ll ans; void solve() { scanf("%d %d %d", &n, &m, &k); for (int i = 1; i <= n; ++i) { for (int j = 1; j <= k; ++j) { scanf("%d %d", &buy[i][j], &sell[i][j]); } } for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { adj[i][j] = -1; } } for (int i = 1; i <= m; ++i) { int u, v, w; scanf("%d %d %d", &u, &v, &w); adj[u][v] = w; } for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { if (adj[i][j] == -1) { dist[i][j] = LINF; } else { dist[i][j] = adj[i][j]; } } dist[i][i] = 0; } for (int k = 1; k <= n; ++k) { for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]); } } } ll ans = 0; for (int i = 2; i <= n; ++i) { if (dist[1][i] == LINF || dist[i][1] == LINF) { continue; } ll b = dist[1][i] + dist[i][1]; for (int j = 1; j <= k; ++j) { if (buy[1][j] != -1 && sell[i][j] != -1) { ll a = sell[i][j] - buy[1][j]; ans = max(ans, a / b); } } } printf("%lld\n", ans); } int main() { int tt = 1; while (tt--) { solve(); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 29 ms | 1272 KB | Output is correct |
2 | Correct | 6 ms | 1272 KB | Output is correct |
3 | Correct | 7 ms | 1272 KB | Output is correct |
4 | Correct | 5 ms | 760 KB | Output is correct |
5 | Correct | 5 ms | 760 KB | Output is correct |
6 | Correct | 5 ms | 760 KB | Output is correct |
7 | Correct | 6 ms | 760 KB | Output is correct |
8 | Correct | 5 ms | 376 KB | Output is correct |
9 | Correct | 5 ms | 760 KB | Output is correct |
10 | Correct | 5 ms | 760 KB | Output is correct |
11 | Correct | 5 ms | 760 KB | Output is correct |
12 | Correct | 5 ms | 376 KB | Output is correct |
13 | Correct | 6 ms | 760 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 760 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 1272 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 760 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |