Gym 100703M It's complicated 水题

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
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;
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值