CodeForces
来源:互联网 发布:如何查看已占用的端口 编辑:程序博客网 时间:2024/06/07 05:34
题目链接:http://codeforces.com/problemset/problem/417/A点击打开链接
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 of c problems, the winners of the round are the first n people in the rating list. Each of the additional elimination rounds consists of d 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 least n·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 and d (1 ≤ c, d ≤ 100) — the number of problems in the main and additional rounds, correspondingly. The second line contains two integers n and m (1 ≤ n, m ≤ 100). Finally, the third line contains an integer k(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 <iostream>#include <algorithm>#include <cstring>#include <vector>#include <stdio.h>#include <string.h>using namespace std;struct xjy{ int weight; int val;};vector < xjy > s;int main(){ int c,d,n,m,k; cin >> c >> d; cin >> n >> m; cin >> k; int num=n*m-k; xjy mid; mid.val=1; mid.weight=d; s.push_back(mid); mid.val=n; mid.weight=c; s.push_back(mid); int maxn=n*m*d; int dp[maxn+5]; memset(dp,0,sizeof(dp)); for(int i=0;i<s.size();i++) for(int j=s[i].weight;j<=maxn;j++) dp[j]=max(dp[j],dp[j-s[i].weight]+s[i].val); int ans=maxn; for(int i=1;i<=maxn;i++) if(dp[i]>=num) { ans=i; break; } if(num<=0) ans=0; cout << ans;}
- codeforces~~~
- Codeforces
- codeforces
- Codeforces
- codeforces
- codeforces
- Codeforces
- Codeforces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- 51Nod 1012 最小公倍数LCM
- 在eclipse中安装jad
- BZOJ-2301-莫比乌斯
- opencv基础之测试质心和圆形度
- console, terminal, tty, pty是啥?
- CodeForces
- python学习笔记
- jdbc操作工具类
- java面试题去除一个int整数的重复数字然后倒着输出
- wdlinux一键安装包
- 【知了堂学习笔记】css3 transform 3d制作字母开门3D效果
- 云计算之路-阿里云上-新车限行:新购服务器无法访问任何远程25端口
- CodeForces
- java--水仙花数计算两种实现方法