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…
http://codeforces.com/contest/864/problem/E 题意: 有一堆物品,每个物品有3个属性,需要的时间,失效的时间(一开始)和价值.只能一件一件的选择物品(即在选择这件物品时需要一定的时间,在这段时间之内不能选择其他物品),选择这件物品只能在失效时间之前选择.问选择的最大价值是多少. 思路: 对于每一个物品,有选和不选两种操作,与01背包是相似的.但是此题选择的顺序会影响到结果,这是01背包不同的地方. 比如 a.st = 3,a.en = 5,a.v = 4…
传送门 题意 给出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…
Codeforces Round #436 (Div. 2) 敲出一身冷汗...感觉自己宛如智障:( codeforces 864 A. Fair Game[水] 题意:已知n为偶数,有n张卡片,每张卡片上都写有一个数,两个人每人选一个数,每人可以拿的卡片必须写有是自己选的数,问能否选择两个数使得两个人每人拿的卡片数一样多并且能拿光卡片.[就是看输入是不是只有两种数字] //:第一遍我看成字符串包含有选的数字也能拿,,这样写着居然过了..水题水题.. #include<cstdio> #inc…
题目链接: http://codeforces.com/problemset/problem/213/B B. Numbers time limit per test 2 secondsmemory limit per test 256 megabytes 问题描述 Furik loves writing all sorts of problems, especially such that he can't solve himself. You've got one of his proble…
题目链接: http://codeforces.com/problemset/problem/214/B Hometask time limit per test:2 secondsmemory limit per test:256 megabytes 问题描述 Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark fo…
D. Kindergarten Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/problem/484/D Description In a kindergarten, the children are being divided into groups. The teacher put the children in a line and associated each child wi…
A. Boredom Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/455/problem/A Description Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and d…
http://codeforces.com/contest/864 第一次打cf的月赛-- A 题意:给你一个数列,问你能不能保证里面只有两种数且个数相等.2<=n<=100,1<=ai<=100. 水--没看完题就交了结果YES的时候还要输出这两种数是什么,然后就+1了-- #include <iostream> #define maxn 105 using namespace std; int n,a,t[maxn],c[maxn],d[maxn]; int mai…
题目链接:https://codeforces.com/contest/1105 C. Ayoub and Lost Array 题目大意:一个长度为n的数组,数组的元素都在[L,R]之间,并且数组全部元素的和可以被3整除,问有多少种方法构建出该数组.答案模1000000007 例 输入 2 1 3 输出 3 note:满足的情况只有[1,2],[2,1],[3,3] 解题思路:用dp[i][j]表示长度为i的数组,元素大小在[L,R]之间,并且元素和模3的余数为j的方案数,我们可以计算出[L,…