Codeforces 417 D. Cunning Gena】的更多相关文章

按monitor排序,然后状压DP... . D. Cunning Gena time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt.…
[题目链接]:http://codeforces.com/problemset/problem/417/D [题意] 有n个人共同完成m个任务; 每个人有可以完成的任务集(不一定所有任务都能完成); (有重叠也无所谓); 然后它完成这些任务需要报酬xi; 同时它需要特殊物品的数量达到ki才会愿意去做这些任务; 这样特殊物品的单价为b; 然后问你完成这m个任务需要花费多少钱. [题解] 假设我们最后选了几个人; 它们能够完成m项任务; 则这个特殊物品的数量应该是这些人里面ki的最大值; 根据这个;…
题目链接:Codeforces 417D Cunning Gena 题目大意:n个小伙伴.m道题目,每一个监视器b花费,给出n个小伙伴的佣金,所须要的监视器数,以及能够完毕的题目序号. 注意,这里仅仅要你拥有的监视器数量大于小伙伴须要的监视器数量就可以. 求最少花费多少金额能够解决全部问题. 解题思路:dp[i],i为一个二进制数.表示完毕这些题目的最小代价,可是这里要注意,由于有个监视器的数量.普通情况下要开一个二维的状态.可是2^20次方有一百万,再多一维的数组会超内存,所以我的做法是将每一…
Cunning Gena CodeForces - 417D 题意 先将小伙伴按需要的监视器数量排序.然后ans[i][j]表示前i个小伙伴完成j集合内题目所需最少钱.那么按顺序枚举小伙伴,用ans[i-1][j]更新ans[i][j]和ans[i][j | 第i个小伙伴能完成题目的集合](更新后一种时答案要加上第i个小伙伴的费用). 由于小伙伴已经按监视器数量排序了,对于每个枚举出的小伙伴i,可以试着将其作为最后一个要求助的小伙伴,那么此时监视器上花的钱就是这个小伙伴所需监视器数量*每个的费用…
题目链接 D. Cunning Gena time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered p…
告诉你若干个(<=100)武器的花费以及武器能消灭的怪物编号,问消灭所有怪物(<=100)的最小花费...当然每个武器可以无限次使用,不然这题就太水了╮(╯▽╰)╭ 这题当时比赛的时候连题都还没看就结束了....赛后一看,果断是重复覆盖... 不过之后一直没敲...然后今天算是补回来吧,同时也把好久以前学的DLX复习一下... DLX的话,双向十字链表...具体的话,百度Google什么的dancing links... 一开始敲的时候还是挺顺利的,因为之前做过几次重复覆盖都是直接拿精确覆盖的…
Football Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status Description One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was div…
A. Elimination time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The finalists of the "Russian Code Cup" competition in 2214 will be the participants who win in one of the elimination ro…
B. Gena's Code 题目连接: http://www.codeforces.com/contest/614/problem/B Description It's the year 4527 and the tanks game that we all know and love still exists. There also exists Great Gena's code, written in 2016. The problem this code solves is: give…
It's the year 4527 and the tanks game that we all know and love still exists. There also exists Great Gena's code, written in 2016. The problem this code solves is: given the number of tanks that go into the battle from each country, find their produ…
B - Gena's Code It's the year 4527 and the tanks game that we all know and love still exists. There also exists Great Gena's code, written in 2016. The problem this code solves is: given the number of tanks that go into the battle from each country,…
http://codeforces.com/contest/812/problem/D 题意: 现在有n个孩子,m个玩具,每次输入x y,表示x孩子想要y玩具,如果y玩具没人玩,那么x就可以去玩,如果y有人玩的话,x就必须等待y玩完后才能玩.如果出现循环,那么这个循环里的孩子都会哭. 现在有q次询问,如果加入x y,会有多少孩子哭. 思路: 建立一棵树,根结点就是第一个玩玩具y的人,它的子树就是等待玩具的人(子树按照等待顺序建树).这样就会形成很多棵树. 这样的话,对于每个询问,我们去找到最后一…
http://codeforces.com/contest/812/problem/B 题意: 有n层楼,每层楼有m个房间,1表示灯开着,0表示灯关了.最两侧的是楼梯. 现在每从一个房间移动到另一个房间需要1时间,走楼梯也需要1时间,求关完所有灯所需的最少时间. 思路: d[i][0]表示第i层楼关完灯后从左边楼梯上楼的最少时间,d[i][1]代表右楼梯. 预处理一下,开两个数组保存每层楼开灯房间的最左边的值和最右边的值,这样也就确定了要走的范围. 对于上面灯全部关了的楼层,可以不用去考虑它.…
题目链接:http://codeforces.com/problemset/problem/812/B B. Sagheer, the Hausmeister time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Some people leave the lights at their workplaces on when they…
#include <stdio.h> #include <string.h> #include <iostream> #include <algorithm> #include <math.h> using namespace std; int flag; +]; int zero; +]; bool Perfect() { int len=strlen(s); ; i<len; i++) ; ]!=; ; } int main() { f…
来自FallDream的博客,未经允许,请勿转载,谢谢. 有毒的一场div2 找了个1300的小号,结果B题题目看错没交  D题题目剧毒 E题差了10秒钟没交上去. 233 ------- A.Sagheer and Crossroads 有一个十字路口,分别给出每个方向左右转和直行以及行人的红绿灯的状态,求有没有可能有行人会被车撞 大判断.  附上大佬@ACMLCZH的代码 #include <cstdio> #include <cstring> ][]; inline int…
[题意概述] 在一个十字路口 ,给定红绿灯的情况, 按逆时针方向一次给出各个路口的左转,直行,右转,以及行人车道,判断汽车是否有可能撞到行人 [题目分析] 需要在逻辑上清晰,只需要把所有情况列出来即可 [AC] #include<bits/stdc++.h> using namespace std; int main() { ][]; ; i <= ; i++) ; j <= ; j++) scanf("%d",&light[i][j]); int an…
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some str…
C. Sagheer and Nubian Market time limit per test  2 seconds memory limit per test  256 megabytes   On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules.…
B. Sagheer, the Hausmeister time limit per test  1 second memory limit per test  256 megabytes   Some people leave the lights at their workplaces on when they leave that is a waste of resources. As a hausmeister of DHBW, Sagheer waits till all studen…
A. Sagheer and Crossroads time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Sagheer is walking in the street when he comes to an intersection of two roads. Each road can be represented as two…
傻逼二分 #include<cstdio> #include<algorithm> using namespace std; typedef long long ll; ll a[100010],b[100010],sum; int n,m; bool check(int x){ for(int i=1;i<=n;++i){ b[i]=a[i]+(ll)i*(ll)x; } sum=0; sort(b+1,b+n+1); for(int i=1;i<=x;++i){ s…
预处理每一层最左侧的1的位置,以及最右侧的1的位置. f(i,0)表示第i层,从左侧上来的最小值.f(i,1)表示从右侧上来. 转移方程请看代码. #include<cstdio> #include<algorithm> using namespace std; int n,m,left[20],right[20],f[20][2]; char a[20][110]; int main(){ scanf("%d%d",&n,&m); for(in…
A. Sagheer and Crossroads time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Sagheer is walking in the street when he comes to an intersection of two roads. Each road can be represented as two…
A Sagheer and Crossroads 水题略过(然而被Hack了 以后要更加谨慎) #include<bits/stdc++.h> using namespace std; int main() { //freopen("t.txt","r",stdin); int a[4][4]; //memset(a,0,sizeof(a)); for(int i=0;i<4;i++) for(int j=0;j<4;j++) scanf(&…
题目链接 题面有点长需耐心读题. A.一个人行道上的人被撞有4种情况 1.所在车道有车驶出 2.右边车道有左转车 3.左边车道有右转车 4.对面车道有直行车 #include <bits/stdc++.h> #define rep(i, j, k) for(int i = j;i <= k;i ++) #define rev(i, j, k) for(int i = j;i >= k;i --) using namespace std; typedef long long ll;…
B. A Lot of Joy Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/problem/A Description Two boys Gena and Petya wrote on two strips of paper the same string s that consisted of lowercase Latin letters. Then each boy took o…
CodeForces Round 199 Div2   完了,这次做扯了,做的时候有点发烧,居然只做出来一道题,差点被绿. My submissions     # When Who Problem Lang Verdict Time Memory 4434550 Sep 9, 2013 11:57:20 AM OIer E - Xenia and Tree GNU C++ Accepted 842 ms 4260 KB 4434547 Sep 9, 2013 11:56:11 AM OIer…
Aragorn's Story Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/problem/148/E Description Our protagonist is the handsome human prince Aragorn comes from The Lord of the Rings. One day Aragorn finds a lot of enemies who…
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题.. 今天,我们来扒一下cf的题面! PS:本代码不是我原创 1. 必要的分析 1.1 页面的获取 一般情况CF的每一个 contest 是这样的: 对应的URL是:http://codeforces.com/contest/xxx 还有一个Complete problemset页面,它是这样的:…