# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
793734 | 2023-07-26T06:03:31 Z | 박상훈(#10058) | Travelling Trader (CCO23_day2problem2) | C++17 | 142 ms | 29036 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n; vector<int> adj[200200]; int a[200200]; namespace foo{ ll dp[200200]; int nxt[200200]; void dfs(int s, int pa = 0){ dp[s] = a[s], nxt[s] = 0; for (auto &v:adj[s]) if (v!=pa){ dfs(v, s); if (dp[s] < dp[v] + a[s]){ dp[s] = dp[v] + a[s]; nxt[s] = v; } } } void solve1(){ dfs(1); printf("%lld\n", dp[1]); vector<int> V; for (int i=1;i;i=nxt[i]){ V.push_back(i); } printf("%d\n", (int)V.size()); for (auto &x:V) printf("%d ", x); printf("\n"); } } // namespace foo namespace bar{ void solve2(){ } } // namespace bar namespace baz{ void solve3(){ } } // namespace baz int main(){ int k; scanf("%d %d", &n, &k); for (int i=1;i<=n-1;i++){ int x, y; scanf("%d %d", &x, &y); adj[x].push_back(y); adj[y].push_back(x); } for (int i=1;i<=n;i++) scanf("%d", a+i); if (k==1) foo::solve1(); else if (k==2) bar::solve2(); else baz::solve3(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4948 KB | Output is correct |
2 | Correct | 3 ms | 4948 KB | Output is correct |
3 | Correct | 103 ms | 14576 KB | Output is correct |
4 | Correct | 98 ms | 14560 KB | Output is correct |
5 | Correct | 100 ms | 14364 KB | Output is correct |
6 | Correct | 87 ms | 15096 KB | Output is correct |
7 | Correct | 68 ms | 15124 KB | Output is correct |
8 | Correct | 79 ms | 14692 KB | Output is correct |
9 | Correct | 142 ms | 29036 KB | Output is correct |
10 | Correct | 129 ms | 21776 KB | Output is correct |
11 | Correct | 71 ms | 14356 KB | Output is correct |
12 | Correct | 2 ms | 4948 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 4948 KB | Unexpected end of file - int64 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 4948 KB | Unexpected end of file - int64 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 4948 KB | Unexpected end of file - int64 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 5076 KB | Unexpected end of file - int64 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 5076 KB | Unexpected end of file - int64 expected |
2 | Halted | 0 ms | 0 KB | - |