题意:有司机,下午路线,晚上路线各n个。给每个司机恰好分配一个下午路线和晚上路线。给出行驶每条路线的时间,如果司机开车时间超过d,则要付加班费d*r。问如何分配路线才能使加班费最少。
 
贪心,其实就是让司机在d时间内空闲时间最小最好。
直接把下午路线时间和晚上路线时间分别排序,然后最小的下午路线时间对一个最大的晚上路线时间。
因为所有下午路线和晚上路线都需要分配,所以说这样贪心是正确的。
//Serene
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
using namespace std;
const int maxn=100+10;
int n,d,r,ans,aft[maxn],nig[maxn]; int aa;char cc;
int read() {
aa=0;cc=getchar();
while(cc<'0'||cc>'9') cc=getchar();
while(cc>='0'&&cc<='9') aa=aa*10+cc-'0',cc=getchar();
return aa;
} int main() {
n=read();d=read();r=read();
while(n) {
ans=0;
for(int i=1;i<=n;++i) aft[i]=read();
for(int i=1;i<=n;++i) nig[i]=read();
sort(aft+1,aft+n+1);sort(nig+1,nig+n+1);
for(int i=1;i<=n;++i) if(aft[i]+nig[n-i+1]>d) ans+=(aft[i]+nig[n-i+1]-d);
printf("%d\n",ans*r);
n=read();d=read();r=read();
}
return 0;
}

  

 
 

UVA11389 The Bus Driver Problem的更多相关文章

  1. 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 ...

  2. The Bus Driver Problem

    题目连接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=90648#problem/G 题意: 给每位司机分配一个白天和晚上的行车路线, ...

  3. UVa 11389 - The Bus Driver Problem 难度:0

    题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...

  4. UVa 11389 (贪心) The Bus Driver Problem

    题意: 有司机,下午路线,晚上路线各n个.给每个司机恰好分配一个下午路线和晚上路线. 给出行驶每条路线的时间,如果司机开车时间超过d,则要付加班费d×r. 问如何分配路线才能使加班费最少. 分析: 感 ...

  5. 【策略】UVa 11389 - The Bus Driver Problem

    题意: 有司机,下午路线,晚上路线各n个.给每个司机恰好分配一个下午路线和晚上路线.给出行驶每条路线的时间,如果司机开车时间超过d,则要付加班费d×r.问如何分配路线才能使加班费最少. 虽然代码看起来 ...

  6. UVA 11389 The Bus Driver Problem 贪心水题

    题目链接:UVA - 11389 题意描述:有n个司机,n个早班路线和n个晚班路线,给每个司机安排一个早班路线和一个晚班路线,使得每个早班路线和晚班路线只属于一个司机.如果一个司机早班和晚班总的驾驶时 ...

  7. 【一坨理论AC的题】Orz sxy大佬

    1.UVA10891 Game of Sum 2.LA4254 Processor . 3.UVA10905 Children's Game 4.UVA11389 The Bus Driver Pro ...

  8. UVA 11389(贪心问题)

    UVA 11389 Time Limit:1000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Description II  ...

  9. cf475A Bayan Bus

    A. Bayan Bus time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

随机推荐

  1. 阿里云香港ECS搭建Shadowscoks

    注(转https://yijingping.github.io/2016/11/29/fanqiang.html) 1 为什么FQ 作为一个技术人员, 最常用的就是Google.StackOverfl ...

  2. openSUSE 安装compass,mkmf.rb can't find,checking for ffi.h...extconf.rb failed

    安装compass时,提示 Fetching: sass-.gem (%) Successfully installed sass- Fetching: ffi-.gem (%) Building n ...

  3. 性能分析神器VisualVM【转】

    性能分析神器VisualVM[转] Posted on 2015-04-17 09:37 WadeXu 阅读(5809) 评论(6) 编辑 收藏 VisualVM 是一款免费的,集成了多个 JDK 命 ...

  4. thinkphp 区间查询

    ThinkPHP支持对某个字段的区间查询,例如: 富瑞华大理石平台厂家哪家好 $map['id'] = array(array('gt',1),array('lt',10)) ; 得到的查询条件是:  ...

  5. VUE环境下获取当前时间并格式化--按秒数更新

    <el-col :span="8"><div class="grid-content title-time"> {{date}}< ...

  6. Error:Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory

    ylbtech-Error:Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerF ...

  7. mtk 的conferrence call建立流程

    (重点看main_log与) 抓mtk log: 1.*#*#82533284#*#*      进入抓log UI 2.*#*#825364#*#*      进入工程模式 3.进入"Lo ...

  8. Python爬虫笔记【一】模拟用户访问之设置请求头 (1)

    学习的课本为<python网络数据采集>,大部分代码来此此书. 网络爬虫爬取数据首先就是要有爬取的权限,没有爬取的权限再好的代码也不能运行.所以首先要伪装自己的爬虫,让爬虫不像爬虫而是像人 ...

  9. 史上最贵域名诞生!360斥资1700万美元买360.com

    昨日,360公司官方人士向腾讯科技确认,公司已斥巨资收购国际顶级域名360.com.传闻这一收购价格为1700万美元,约合人民币1.1亿元. 史上最贵域名诞生!360斥资1700万美元买360.com ...

  10. python 创建txt每行写入

    txtPath=os.path.join(vocDir,"eval.txt") with open(txtPath,"w") as f: f.writeline ...