# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
68113 | 2018-08-16T00:40:21 Z | thebes | Dostavljač (COCI18_dostavljac) | C++14 | 224 ms | 4820 KB |
#include <bits/stdc++.h> using namespace std; const int MN = 505; typedef long long ll; ll dp[MN][MN], en[MN][MN], arr[MN], N, T, i, j, k, x, y; vector<int> adj[MN]; void solve(int n,int p){ for(auto v : adj[n]) if(v != p) solve(v, n); for(auto v : adj[n]){ if(v == p) continue; for(j=1;j+2<=T;j++){ for(k=T;k>=j+2;k--) en[n][k]=max(en[n][k],en[n][k-j-2]+dp[v][j]); for(k=T;k>=j+2;k--) en[n][k]=max(en[n][k],dp[n][k-j-1]+en[v][j]); for(k=T;k>=j+2;k--) dp[n][k]=max(dp[n][k],dp[n][k-j-2]+dp[v][j]); } } for(j=T;j>=1;j--){ en[n][j]=max(en[n][j],en[n][j-1]+arr[n]); dp[n][j]=max(dp[n][j],dp[n][j-1]+arr[n]); } } int main(){ for(scanf("%lld%lld",&N,&T),i=1;i<=N;i++) scanf("%lld",&arr[i]); for(i=1;i<N;i++){ scanf("%lld%lld",&x,&y); adj[x].push_back(y); adj[y].push_back(x); } solve(1, 0); printf("%lld\n",en[1][T]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 636 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 804 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 860 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 1152 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 10 ms | 1392 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 1780 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 56 ms | 2176 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 24 ms | 3160 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 127 ms | 3932 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 224 ms | 4820 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |