codeforce E. Fire背包】的更多相关文章

E. Fire time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Polycarp is in really serious trouble — his house is on fire! It's time to save the most valuable items. Polycarp estimated that it…
E. Fire time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Polycarp is in really serious trouble - his house is on fire! It's time to save the most valuable items. Polycarp estimated that it…
2017-08-25 17:04:07 writer:pprp 题目描述: • Codeforces 35C Fire Again• N*M的格子,最开始有K个点 (坐标给定) 开始着火• 每一秒着火的点会扩散到与其距离为1的其他点• 求最后一个着火的点• 1 ≤ n, m ≤ 2000• 1 ≤ K ≤ 10 模拟的题,本来想用dfs做感觉有点复杂, 可以通过判断两个点之间横纵距离之和来计算出时间 参见的是cf上某位大佬的代码,差距还是很大,要加油了, 话说cf真是好,越来越觉得cf好用了 代…
题目链接:http://codeforces.com/contest/864/problem/E 题解:这题一看就很像背包但是这有3维限制也就是说背包取得先后也会对结果有影响.所以可以考虑sort来降低维度(这是常用的方法) 然后就是简单的有限背包至于这题还要求存下娶了哪些东西可以用vector来存. #include <iostream> #include <cstring> #include <cstdio> #include <vector> #inc…
H - Fire Drill Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Practice UVALive 5066 Description Joko is taking part in a fire drill which is held by the Jakarta Fire Department to recruit new firemen. The drill i…
E. Fire http://codeforces.com/problemset/problem/864/E Polycarp is in really serious trouble — his house is on fire! It's time to save the most valuable items. Polycarp estimated that it would take ti seconds to save i-th item. In addition, for each…
01背包变形,注意dp过程的时候就需要取膜,否则会出错. 代码如下: #include<iostream> #include<cstdio> #include<cstring> using namespace std; #define MAXW 15005 #define N 155 #define LL long long #define MOD 1000000007 int w1[N],w2[N]; LL dp1[MAXW],dp2[MAXW]; int main(…
题意:失火了,有n个物品,每个物品有价值pi,必须在时间di前(小于di)被救,否则就要被烧毁.救某个物 品需要时间ti,问最多救回多少价值的物品,并输出救物品的顺序. Examples Input 33 7 42 6 53 7 6 Output 1122 3 Input 25 6 13 3 5 Output 111 思路:有点像一个背包,dp数组记录的是当前时间所能获得的最大价值,转移方程dp[j]=max(dp[j],dp[j-t[i].ti]+t[i].w) path[i][j]表示到i号…
背包DP,决策的时候记一下 jc[i][j]=1 表示第i个物品容量为j的时候要选,输出方案的时候倒推就好了 #include<iostream> #include<cstdlib> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; ; struct poi{int t,ddl,p,id;}a[maxn]; int n,top,ansi,cnt;…
传送门 题意 给出n种物品,抢救第\(i\)种物品花费时间\(t_i\),价值\(p_i\),截止时间\(d_i\) 询问抢救的顺序及物品价值和最大值 分析 按\(d_i\)排序的目的是防止以下情况 4 8 100 1 2 100 不排序只能选择第一个物品 (请仔细思考) 那么排序后做一遍背包,排序后选择顺序必定是递增的,求路径时从n往前找,具体见代码 code #include<bits/stdc++.h> using namespace std; #define ll long long…