# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
101543 | 2019-03-19T03:58:03 Z | shenxy | Chase (CEOI17_chase) | C++11 | 502 ms | 525312 KB |
#include <cstdio> #include <algorithm> #include <vector> using namespace std; int n, v; vector<long long int> p; vector< vector<int> > adjlist; vector< vector<int> > children; vector< vector< vector<long long int> > > dptable; long long int smalldp(int v, int pa, int crumbs) { if (dptable[v][pa][crumbs] != -1) return dptable[v][pa][crumbs]; if (crumbs == 0) return 0; long long int ans = 0, maxdp = 0, maxnocrumb = 0; for (int i = 0; i < adjlist[v].size(); i++) { if (adjlist[v][i] == pa) continue; ans += p[adjlist[v][i]]; maxdp = max(maxdp, smalldp(adjlist[v][i], v, crumbs - 1)); maxnocrumb = max(maxnocrumb, smalldp(adjlist[v][i], v, crumbs)); } return dptable[v][pa][crumbs] = max(maxdp + ans, maxnocrumb); } int main() { scanf("%d %d", &n, &v); long long int nextint; for (int i = 0; i < n; i++) { scanf("%lld", &nextint); p.push_back(nextint); adjlist.push_back(vector<int>()); } int a, b; for (int i = 1; i < n; i++) { scanf("%d %d", &a, &b); adjlist[a - 1].push_back(b - 1); adjlist[b - 1].push_back(a - 1); } if (n <= 1000) { for (int i = 0; i < n; i++) { dptable.push_back(vector< vector<long long int> >(n + 1, vector<long long int>(v + 1, -1))); } long long int ans = 0; for (int i = 0; i < n; i++) { ans = max(ans, smalldp(i, n, v)); } printf("%lld\n", ans); return 0; } else { printf("HIHIHIHIHIHIWRONGANSWER"); return 0; for (int i = 0; i < n; i++) { dptable.push_back(vector< vector<long long int> >(v, {-1})); children.push_back(vector<int>()); } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 3 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 3 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Runtime error | 502 ms | 525312 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 75 ms | 7324 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 3 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Runtime error | 502 ms | 525312 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
8 | Halted | 0 ms | 0 KB | - |