Elimination(DP)
来源:互联网 发布:聚合数据看不懂 编辑:程序博客网 时间:2024/06/05 05:13
The finalists of the "Russian Code Cup" competition in 2214 will be the participants who win in one of the elimination rounds.
The elimination rounds are divided into main and additional. Each of the main elimination rounds consists ofc problems, the winners of the round are the firstn people in the rating list. Each of the additional elimination rounds consists ofd problems. The winner of the additional round is one person. Besides,k winners of the past finals are invited to the finals without elimination.
As a result of all elimination rounds at least n·m people should go to the finals. You need to organize elimination rounds in such a way, that at leastn·m people go to the finals, and the total amount of used problems in all rounds is as small as possible.
The first line contains two integers c andd (1 ≤ c, d ≤ 100) — the number of problems in the main and additional rounds, correspondingly. The second line contains two integersn and m (1 ≤ n, m ≤ 100). Finally, the third line contains an integerk (1 ≤ k ≤ 100) — the number of the pre-chosen winners.
In the first line, print a single integer — the minimum number of problems the jury needs to prepare.
1 107 21
2
2 22 12
0
#include<stdio.h>#include<algorithm>#include<string.h>#define MAX 100000using namespace std;int val[MAX];int w[MAX];int dp[MAX];int main(){ memset(dp,0,sizeof(dp)); int n,m,c0,d0; int a,b,c,d; scanf("%d%d%d%d",&n,&m,&c0,&d0); int cnt=1,j; int k=n/c0; for(j=1;j<=k;j++){ val[cnt]=d0; w[cnt++]=c0; } int i; for(i=0;i<m;i++){ scanf("%d%d%d%d",&a,&b,&c,&d); k=min(n/c,a/b); for(j=1;j<=k;j++){ val[cnt]=d; w[cnt++]=c; } } for(i=1;i<cnt;i++){ for(j=n;j>=w[i];j--) dp[j]=max(dp[j],dp[j-w[i]]+val[i]); } printf("%d\n",dp[n]);return 0;}
- Elimination(DP)
- Elimination
- 8VC Venture Cup 2016 - Elimination Round F. Group Projects(DP)
- 8VC Venture Cup 2016 - Elimination Round F. Group Projects(DP)★ ★
- 【 IndiaHacks 2nd Elimination 2017】A. Binary Blocks(DP 思维)
- 高斯消元(Gauss-Jordan Elimination)
- 12219 - Common Subexpression Elimination(表达式树)
- CROC 2016 - Elimination Round(A)bfs
- 【紫书】(UVa12219)Common Subexpression Elimination
- HDU 4975 A simple Gaussian elimination problem. 网络流+矩阵上的dp
- CROC 2016 - Elimination Round (Rated Unofficial Edition) E. Intellectual Inquiry 贪心 构造 dp
- Codeforces Round #380 Technocup 2017 - Elimination Round 2 F. Financiers Game DP+状态简化
- Codeforces 838E IndiaHacks 2nd Elimination 2017 mirror Convex Countour :毛线DP啊
- 算法实战1:爱消除(Elimination Game)
- hdu - 4975 - A simple Gaussian elimination problem.(最大流)
- UVA 12219 Common Subexpression Elimination (dfs瞎搞)
- Gaussian elimination
- codeforces Elimination
- 32. Longest Valid Parentheses
- 关于java中的try-catch-finally语句和return
- ZZULIOJ【2178】GJJ来签到【水题】
- struts2.5之通配符使用报错
- [SDUT](3379)数据结构实验之查找七:线性之哈希表 ---哈希查找(查找)
- Elimination(DP)
- Java快排实现
- 原型函数的类型
- Hdu 1713 相遇周期
- 第一次机房收费系统错误总结
- 简单计时器的制作
- hdu
- 基于距离的地图聚类算法, Java实现
- bzoj3289 Mato的文件管理