UVa 11389 - The Bus Driver Problem 难度:0
题目
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2384
题意
n个司机,n个白天路线,n个晚上路线,要求每个司机一个白天一个晚上路线。设司机2个路线所需时间超出d部分为加班工时,需额外给r元/h。问总加班支出最小是多少。
思路
明显,要分的均匀。一个数组大到小,一个数组小到大,依次序组合即可
代码
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;
const int MAXN = 1e3 + ;
typedef pair<int, int> Pair;
int a[MAXN];
int b[MAXN];
int n, d, r;
int main() {
int T;
//scanf("%d", &T);
freopen("C:\\Users\\Iris\\source\\repos\\ACM\\ACM\\input.txt", "r", stdin);
//freopen("C:\\Users\\Iris\\source\\repos\\ACM\\ACM\\output.txt", "w", stdout);
for (int ti = ; scanf("%d%d%d", &n, &d, &r) == && n; ti++) {
for (int i = ; i < n; i++) {
scanf("%d", a + i);
}
sort(a, a + n);
for (int i = ; i < n; i++) {
scanf("%d", b + i);
}
sort(b, b + n);
int ans = ;
for (int i = ; i < n; i++) {
ans += max(, a[i] + b[n - - i] - d);
}
printf("%d\n", ans * r);
}
return ;
}
UVa 11389 - The Bus Driver Problem 难度:0的更多相关文章
- UVA 11389 The Bus Driver Problem
题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82842#problem/D In a city there are n bus ...
- UVA 11389 The Bus Driver Problem 贪心水题
题目链接:UVA - 11389 题意描述:有n个司机,n个早班路线和n个晚班路线,给每个司机安排一个早班路线和一个晚班路线,使得每个早班路线和晚班路线只属于一个司机.如果一个司机早班和晚班总的驾驶时 ...
- 【策略】UVa 11389 - The Bus Driver Problem
题意: 有司机,下午路线,晚上路线各n个.给每个司机恰好分配一个下午路线和晚上路线.给出行驶每条路线的时间,如果司机开车时间超过d,则要付加班费d×r.问如何分配路线才能使加班费最少. 虽然代码看起来 ...
- UVa 11389 (贪心) The Bus Driver Problem
题意: 有司机,下午路线,晚上路线各n个.给每个司机恰好分配一个下午路线和晚上路线. 给出行驶每条路线的时间,如果司机开车时间超过d,则要付加班费d×r. 问如何分配路线才能使加班费最少. 分析: 感 ...
- UVa 10970 - Big Chocolate 水题 难度: 0
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
- UVa 11210 - Chinese Mahjong 模拟, 枚举 难度: 0
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
- Uva LA 3902 - Network 树形DP 难度: 0
题目 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_pr ...
- Uva 11520 - Fill the Square 贪心 难度: 0
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
- The Bus Driver Problem
题目连接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=90648#problem/G 题意: 给每位司机分配一个白天和晚上的行车路线, ...
随机推荐
- bzoj4710 [Jsoi2011]分特产(容斥)
4710: [Jsoi2011]分特产 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 814 Solved: 527[Submit][Status] ...
- time模块和os模块,json模块
import time # def month(n): # time.local() # struct_time=time.strptime("%Y-%m-1","%Y- ...
- vue+vuex 回退定位到初始位置
先放出两张图(没错,你还在9012,做为一名资深设计师我唯一的技能点就是留白),简单说明下问题未做回退定位(从落地页回退,每次都回到A位置)想死啊有木有,每次都需要手动重新定位来选择,你大哥看到你做个 ...
- 20165306 Exp4 恶意代码分析
Exp4 恶意代码分析 一.实践概述 1.实践目标 1.1是监控你自己系统的运行状态,看有没有可疑的程序在运行. 1.2是分析一个恶意软件,就分析Exp2或Exp3中生成后门软件:分析工具尽量使用原生 ...
- 【python】 迭代器、生成器、列表推导式
一.可迭代对象.迭代器 1.可以被for循环的数据类型(可迭代对象): 字符串(str).列表(list).字典(dict).元祖(tuple).range() 2.迭代器 2.1 将可迭代对象==& ...
- 【python 3】 字典方法操作汇总
基础数据类型:tuple 1.1 新增 dic["key"] = value 字典中没有key就添加,有key就覆盖 dic ...
- 哆啦A梦css
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- chat聊天系统项目
项目名称:实现一个在线聊天系统? 一.需求 1. 海量用户在线聊天系统:2. 用户登录注册:3. 根据用户ID或者Nickname搜索并添加用户:4. 动态知道好友上下线:5. 可以创建群并添加好友到 ...
- vue eventBus使用
类似于iframe之间的possMessage方式传参 1.eventBus.js文件 //用于兄弟组件通信 import Vue from 'vue'; export default new Vue ...
- HDOJ-2011
#include<iostream> #include<cstdio> using namespace std; int main(){ int m,n,i; float su ...