uva 11389 - The Bus Driver Problem(贪心)
来源:互联网 发布:java有链表吗 编辑:程序博客网 时间:2024/05/24 02:38
题目链接:uva 11389 - The Bus Driver Problem
题目大意:有n个司机,n条下午路线和n条晚上路线,先在要给每个司机安排一条下午路线和一条晚上路线,如果司机的工作时间超过d,则要按照每小时r元增加加班费,问最少需支付多少加班费。
解题思路:贪心,下午最大的搭配晚上最小的,一次类推。
#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;const int N = 105;int n, d, r, after[N], even[N];void init() {for (int i = 0; i < n; i++) scanf("%d", &after[i]);for (int i = 0; i < n; i++) scanf("%d", &even[i]);sort(after, after + n);sort(even, even + n);}int solve() {int ans = 0, p = 0;for (int i = n - 1; i >= 0; i--) {int c = after[i] + even[p++];if (c > d) ans += c - d;}return ans;}int main () {while (scanf("%d%d%d", &n, &d, &r) == 3 && n && d && r) {init();printf("%d\n", solve() * r);}return 0;}
1 0
- UVA 11389 - The Bus Driver Problem (贪心)
- UVA - 11389 The Bus Driver Problem 贪心
- UVA 11389 The Bus Driver Problem(贪心)
- UVA 11389 The Bus Driver Problem(贪心)
- uva 11389 - The Bus Driver Problem(贪心)
- UVA 11389 The Bus Driver Problem(贪心)
- 11389 - The Bus Driver Problem(贪心)
- Uva Oj 11389 - The Bus Driver Problem
- Uva-11389-The Bus Driver Problem
- uva 11389 The Bus Driver Problem
- UVA - 11389 The Bus Driver Problem
- UVA 11389 - The Bus Driver Problem
- UVa 11389 - The Bus Driver Problem
- UVA - 11389 The Bus Driver Problem
- 【UVa】11389 - The Bus Driver Problem
- UVa 11389 The Bus Driver Problem
- UVA - 11389 The Bus Driver Problem
- UVA 11389 The Bus Driver Problem .
- 体验引用
- Web敏捷开发1.Hello Rails基础知识
- 东软实训心得:海阔天空
- ORACEL 修改表结构
- Solr4.40 如何配置使用UUID自动生成id值
- uva 11389 - The Bus Driver Problem(贪心)
- ubuntu13.10 源码安装Mplayer,解决播放无声音问题
- 如何把变量或者数组定义到SDRAM及任意位置
- JQuery Progress Bar
- 记录spring的一些注解问题
- TexturePacker 图片加密
- maven学习资料
- 高效判断一个数是否是2的幂次方
- post和get的区别