Gym 100703M It's complicated 水题
2015-07-27 20:05
357 查看
M. It's complicated
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Dragon was drinking tea on a balcony and admiring a very beautiful sunset. Two outgoing silhouettes were still descrying in the rays of a setting sun. Of course, Princess promised to visit Dragon sometime, but what could be a reason for her to come back in
the Castles Valley?..
Dragon decided to cook biscuits according to a recipe that was told him by Princess. So he needs to check if he has sufficient quantity of ingredients for it. Of course, he has a few of ginger, cinnamon, cloves and cardamon... But, comparing to making tea,
he needs some more ingredients to bake biscuits.
Dragon revised all his ingredients, and knew how many units of each ingredient he had.
It was written in the recipe how many units of each ingredient are required to bake a biscuit. Certainly, Dragon wanted to bake an integer number of biscuits.
Dragon realized that he will expend some ingredients completely, while some other ingredients will remain. He believed he must purchase some extra ingredients, so that all ingredients will be completely expended after baking some number of biscuits.
Dragon knew the cost for a unit of each ingredient. Your task is to figure out minimum amount of money which is needed to spend to fulfil the condition above.
Input
The first line contains integer n (1 ≤ n ≤ 10) —
the number of ingredients.
The second line contains n integers q1, q2, ..., qn (1 ≤ qj ≤ 100, j = 1, 2, ..., n), qj —
the number of units of jth ingredient, which Dragon has.
The third line contains n integers c1, c2, ..., cn (1 ≤ cj ≤ 10, j = 1, 2, ..., n), cj —
the number of units of jth ingredient which it needs for cooking a biscuit.
The fourth line contains n integers p1, p2, ..., pn (1 ≤ pj ≤ 100, j = 1, 2, ..., n), pj —
cost of a unit of jth ingredient.
Output
Print the only integer — minimum amount of money to spend.
Sample test(s)
input
output
题目链接:http://codeforces.com/gym/100703/problem/M
AC代码:
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Dragon was drinking tea on a balcony and admiring a very beautiful sunset. Two outgoing silhouettes were still descrying in the rays of a setting sun. Of course, Princess promised to visit Dragon sometime, but what could be a reason for her to come back in
the Castles Valley?..
Dragon decided to cook biscuits according to a recipe that was told him by Princess. So he needs to check if he has sufficient quantity of ingredients for it. Of course, he has a few of ginger, cinnamon, cloves and cardamon... But, comparing to making tea,
he needs some more ingredients to bake biscuits.
Dragon revised all his ingredients, and knew how many units of each ingredient he had.
It was written in the recipe how many units of each ingredient are required to bake a biscuit. Certainly, Dragon wanted to bake an integer number of biscuits.
Dragon realized that he will expend some ingredients completely, while some other ingredients will remain. He believed he must purchase some extra ingredients, so that all ingredients will be completely expended after baking some number of biscuits.
Dragon knew the cost for a unit of each ingredient. Your task is to figure out minimum amount of money which is needed to spend to fulfil the condition above.
Input
The first line contains integer n (1 ≤ n ≤ 10) —
the number of ingredients.
The second line contains n integers q1, q2, ..., qn (1 ≤ qj ≤ 100, j = 1, 2, ..., n), qj —
the number of units of jth ingredient, which Dragon has.
The third line contains n integers c1, c2, ..., cn (1 ≤ cj ≤ 10, j = 1, 2, ..., n), cj —
the number of units of jth ingredient which it needs for cooking a biscuit.
The fourth line contains n integers p1, p2, ..., pn (1 ≤ pj ≤ 100, j = 1, 2, ..., n), pj —
cost of a unit of jth ingredient.
Output
Print the only integer — minimum amount of money to spend.
Sample test(s)
input
3 15 8 10 2 3 5 12 1 4
output
148
题目链接:http://codeforces.com/gym/100703/problem/M
AC代码:
#include <bits/stdc++.h> using namespace std; typedef long long LL; #define MAXN 110 //1e6 #define y1 y234 int n; int q[MAXN], c[MAXN], p[MAXN]; int main() { scanf("%d", &n); for(int i = 1; i <= n; i++) { scanf("%d", &q[i]); } for(int i = 1; i <= n; i++) { scanf("%d", &c[i]); } for(int i = 1; i <= n; i++) { scanf("%d", &p[i]); } int maxx = 0; for(int i = 1; i <= n; i++) { maxx = max(maxx, (q[i] + c[i] - 1) / c[i]); } int ans = 0; for(int i = 1; i <= n; i++) { ans += p[i] * (maxx * c[i] - q[i]); } printf("%d\n", ans); return 0; }
相关文章推荐
- 【基础练习】【快速幂】codevs3285 转圈游戏题解
- 溢出之后
- uva11059(最大乘积)
- Swift开发教程--如何播放图片动画
- 最近半年工作总结
- NSString中stringWithFormat的用法
- 一起talk C栗子吧(第二十五回:C语言实例--二分查找)
- 第二章 知识图谱——机器大脑中的知识库
- javascript的AMD规法--esl与requirejs浅介。
- nginx的fastcgi配置
- 正则表达式!!!
- 【linux高级程序设计】(第九章)进程间通信-管道 3
- 九度oj 1194
- OS monitor
- eclipse创建maven管理的web项目
- 文本处理工具AWK详解
- c++实现哈希表
- http格式(graph)
- XHTML基础
- 杭电ACM1284——钱币兑换问题