ZOJ 3626 Treasure Hunt I 树上DP】的更多相关文章

E - Treasure Hunt I Time Limit:2000MS Memory Limit:65536KB Description Akiba is a dangerous country since a bloodsucker living there. Sometimes the bloodsucker will appear and kill everyone who isn't at his hometown. One day, a brave person named CC…
Treasure Hunt I Time Limit: 2 Seconds      Memory Limit: 65536 KB Akiba is a dangerous country since a bloodsucker living there. Sometimes the bloodsucker will appear and kill everyone who isn't at his hometown. One day, a brave person named CC finds…
题意:给一棵树,一个人站在节点s,他有m天时间去获取各个节点上的权值,并且最后需要回到起点s,经过每条边需要消耗v天,问最少能收获多少权值? 思路: 常规的,注意还得跑回原地s. //#include <bits/stdc++.h> #include <iostream> #include <cstdio> #include <cstring> #include <map> #include <algorithm> #include…
H - Treasure Hunt IV Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Description Alice is exploring the wonderland, suddenly she fell into a hole, when she woke up, she found there are b - a + 1 treasures labled a from b in…
本文出自   http://blog.csdn.net/shuangde800 题目链接:zoj-3627 题意 直线上有n个城市, 第i个城市和i+1个城市是相邻的.  每个城市都有vi的金币.    Alice和Bob站在城市p, 他们每天可以选择走向一个相邻的城市, 也可以选择不走. 他们是单独行动的.    他们经过一个城市就可以获得相应的金币(不能重复获得)    作为一个队伍, 他们的最远距离不能操作M, 问T天内, 他们最多一共能拿多少金币? 思路 由于每次只能走一步,那么一定是一…
题意:有n个城市并排着,每个城市有些珠宝,有两个人站在第s个城市准备收集珠宝,两人可以各自行动,但两人之间的距离不能超过dis,而且每经过一个城市就需要消耗1天,他们仅有t天时间收集珠宝,问最多能收集多少珠宝? 思路: 其实就是类似一个滑动窗口在收集一个序列上的权值.首先两个人可以同时往两边散开,直到极限距离dis(这样省时),然后他们可能往左/右走,也可能往左走一会儿再往右走,也可能往右走一会儿再往左走.可以看出其实这些考虑都是对称的,那么我们主要考虑1边就行了.可以尝试枚举往左边走k天,其他…
[ZOJ3626]Treasure Hunt I Time Limit: 2 Seconds      Memory Limit: 65536 KB Akiba is a dangerous country since a bloodsucker living there. Sometimes the bloodsucker will appear and kill everyone who isn't at his hometown. One day, a brave person named…
题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3626 题目大意:树中取点.每过一条边有一定cost,且最后要回到起点.给定预算m,问最大价值. 解题思路: 首先要注意这题要回到起点,由于树的特殊结构(每个结点只有一个父亲)也就是说,要回到开头, 开销是2倍.所以首先m/=2. 然后就是树形背包的求解,这题的cost在边,所以for写法变成如下: for(m....j....0)     for(0....k…
Treasure Hunt IV Time Limit: 2 Seconds      Memory Limit: 65536 KB Alice is exploring the wonderland, suddenly she fell into a hole, when she woke up, she found there are b - a + 1 treasures labled a from b in front of her.Alice was very excited but…
Treasure Hunt IV Time Limit: 2 Seconds      Memory Limit: 65536 KB Alice is exploring the wonderland, suddenly she fell into a hole, when she woke up, she found there are b - a + 1 treasures labled a from b in front of her. Alice was very excited but…