URAL - 1788 On the Benefits of Umbrellas(水题)
来源:互联网 发布:淘宝优惠券在哪里领取 编辑:程序博客网 时间:2024/05/18 18:45
On the Benefits of Umbrellas
Time Limit: 1000MS Memory Limit: 65536KB 64bit IO Format: %I64d & %I64u
Description
A group of school leavers had their graduation party at an aquapark. They had a great time, but when they were leaving the aquapark they were surprised by a suddenly cold weather and a heavy rain, which made it quite a problem to get to the trolleybus stop.
It turned out that all the boys in the company had their umbrellas and all the girls were without umbrellas. Of course, each boy, being a real gentleman, volunteered to accompany one of the girls to the trolleybus stop under his umbrella.
If the ith girl gets wet under the rain, she'll get upset by gi units. If no girl accepts an invitation from the jth boy, he'll get upset by bj · k units, where k is the number of luckier boys who will accompany girls under their umbrellas. The girls who will go under umbrellas and the accompanying boys will not get upset at all.
Help the boys and girls keep their holiday mood as unspoiled as possible. Determine how they should proceed to make the total upset minimal.
Input
The first line contains the number of girls n and boys m in the group (1 ≤ n, m ≤ 100). The second line contains the girls' upsets g1, …, gnseparated with a space. The third line contains the boys' upset coefficients b1, …, bm separated with a space. The numbers in the second and third lines are positive integers not exceeding 1000.
Output
Output the minimal possible total upset.
Sample Input
2 41 10010 8 6 4
19
1<=n,m<=100,于是直接枚举就好了。
#include<iostream>#include<algorithm>using namespace std;bool cmp(int a, int b){return a > b;}int main(){int n, m;int a[105], b[105];while (cin >> n >> m){for (int i = 0; i < n; i++)cin >> a[i];for (int i = 0; i < m; i++)cin >> b[i];sort(a, a + n, cmp);sort(b, b + m, cmp);int ans = 10e6;int d = min(n, m);for (int i = 0; i <= d; i++){int temp1 = 0, temp2 = 0, temp;for (int j = i; j < n; j++)temp1 += a[j];for (int j = i; j < m; j++)temp2 += b[j];temp = temp1 + temp2*i;ans = min(ans, temp);}cout << ans << endl;}}
0 0
- URAL - 1788 On the Benefits of Umbrellas(水题)
- URAL 1788On the Benefits of Umbrellas
- URAL 1788 On the Benefits of Umbrellas
- 01. The Benefits of JanusGraph
- Benefits of Using the .NET Framework
- The Benefits of Hiring a Janitorial Service_111
- Reap the benefits of document style Web services
- Goodbye, Silos: The Benefits of Converged Data Centers
- What are the benefits of PreparedStatement over Statement
- book1 unit2 after-class reading 2 : The Benefits of Forgetting
- Benefits of Internet EDI
- Benefits of Code Refactoring
- Benefits of software localization
- URAL 1016. Cube on the Walk(搜索)比较难
- ural 1207. Median on the Plane(极角排序)
- Ural 1207. Median on the Plane(计算几何)
- ural 1932 The Secret of Identifier (容斥原理)
- POJ 2366 (URAL 1021)Sacrament of the Sum
- 百度蜘蛛抓取规则 Baiduspider
- Linux平台下使用rman进行oracle数据库迁移
- POJ 1251 解题报告
- 新版本Android SDK 找不到adb.exe的
- listview的重写方法getview的优化
- URAL - 1788 On the Benefits of Umbrellas(水题)
- 黑马程序员-----List,Set集合
- [C++Primer]第2章.变量和基本类型
- Oracle 数据库安装规范--database所在路径和归档目录所在路径必须分开
- dede 代码调用 参数问题
- Servlet源码解析:Session、Request以及Response
- 《淘宝技术这十年》读书笔记 (一).淘宝网技术简介及来源
- 黑马程序员-----泛型,Map集合
- whuoj 1566 Spanning Tree (动态MST,简单)