dp uva12186树上的动态规划
来源:互联网 发布:php 数组键值排序 编辑:程序博客网 时间:2024/05/16 06:32
题目链接
d(u)表示让u给上级发信最少需要多少工人
#include <bits/stdc++.h>using namespace std;const int maxn = 1e5+10;int N,T,f;vector<int> sons[maxn];int dp(int u){if(sons[u].empty()) return 1;int k = sons[u].size();vector<int> d;for(int i=0; i<k; i++)d.push_back(dp(sons[u][i]));sort(d.begin(),d.end());int c = (k*T-1)/100 + 1;int ans = 0;for(int i=0; i<c; i++) ans += d[i];return ans;}int main(){while(scanf("%d%d",&N,&T)==2 && (N||T)){for(int i=0; i<=N; i++) sons[i].clear();for(int i=1; i<=N; i++){scanf("%d",&f);sons[f].push_back(i);}printf("%d\n",dp(0));}}
0 0
- dp uva12186树上的动态规划
- uva12186 树上的dfs
- 树上的动态规划
- 树上的动态规划
- 动态规划专题:树上DP和状态压缩DP
- 工人的请愿 树形DP uva12186
- 树上的动态规划;树的最大独立集;刷表DP,子问题彼此独立没有交集; 无根树转化有根树;
- UVA 11468 Substring(AC自动机+树上的动态规划)
- UVA12186 树形DP
- 树上的DP
- 树上的 DP
- uva 12186 - Another Crisis-树上动态规划
- POJ2342[Anniversary party] 树上动态规划
- UVA1218[Perfect Service] 树上动态规划模型
- UVA12186--- Another Crisis (树形dp)
- UVA12186 Another Crisis dp 题解
- 树形dp,工人请愿书 uva12186
- 面试会考的动态规划DP总结
- 442. Find All Duplicates in an Array(LeetCode)
- 洛谷 P3365 改造二叉树
- 单利模式工厂模式和观察者模式
- PEP8
- WS激活码
- dp uva12186树上的动态规划
- jquery resize() 的妙用
- 为什么你的项目总是延期?
- Linux kernel Hash list
- Discuz! 产品的变量分析
- Python Logistic 回归分类
- C++中自定义异常的抛出与捕获
- Vulkan Tutorial(2)
- [C++]链表中删除连续重复出现的结点