# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
951994 | 2024-03-23T03:32:03 Z | vjudge1 | Museum (CEOI17_museum) | C++17 | 20 ms | 28508 KB |
#include<bits/stdc++.h> using namespace std; const int MAXN=10005; int n,m,x,son[MAXN],dp[MAXN][MAXN]; struct node{int to,cost;}; vector<node>g[MAXN]; void dfs(int u,int fa){ for(auto i:g[u]){ int v=i.to; if(v==fa) continue; dfs(v,u);son[u]+=son[v]+1; for(int j=min(m-1,son[u]);j>=0;j--) for(int k=min(j-1,son[v]);k>=0;k--) dp[u][j]=max(dp[u][j],dp[u][j-k-1]+dp[v][k]+i.cost); } } int main(){ scanf("%d%d%d",&n,&m,&x); for(int i=1;i<=n-1;i++){ int u,v,c;scanf("%d%d%d",&u,&v,&c); g[u].push_back({v,c}); g[v].push_back({u,c}); } dfs(x,0); printf("%d",dp[x][m-1]); return 0;; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2652 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 20 ms | 28508 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 20 ms | 28508 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2652 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |