题意:有司机,下午路线,晚上路线各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. linux常用软连接使用ln -s

    [软连接]另外一种连接称之为符号连接(Symbolic Link),也叫软连接.软链接文件有类似于Windows的快捷方式.它实际上是一个特殊的文件.在符号连接中,文件实际上是一个文本文件,其中包含的 ...

  2. 2019-6-23-天河2-程序-version-GLIBCXX_3.4.21-not-found-解决方法

    title author date CreateTime categories 天河2 程序 version GLIBCXX_3.4.21 not found 解决方法 lindexi 2019-06 ...

  3. Linux 下 Nand Flash 调用关系

    Nand Flash 设备添加时数据结构包含关系 struct mtd_partition        partition_info[] --> struct s3c2410_nand_set ...

  4. drupal-note2 drush运行make文件

    进入durpal项目的根目录中执行 drush make build-openpublic.make /path/to/webroot 参考: Managing Drush make files fo ...

  5. CF961F k-substring

    题意:给你一个字符串(sl<=1e6),问每一个起点到1和终点到sl距离相等的子串的最长不等于串长的border. 标程: #include<cstdio> #include< ...

  6. 一个简单的SpringBoot入门程序

    1. 使用IDEA构建Maven项目 <?xml version="1.0" encoding="UTF-8"?> <project xmln ...

  7. 杂项-公司:Google

    ylbtech-杂项-公司:Google 谷歌公司(Google Inc.)成立于1998年9月4日,由拉里·佩奇和谢尔盖·布林共同创建,被公认为全球最大的搜索引擎公司.谷歌是一家位于美国的跨国科技企 ...

  8. PKU--1267 Cash Machine(多重背包)

    题目http://poj.org/problem?id=1276 分析 这是一个多重背包的问题,可以把请求的金额当作背包的重量,而货币的面值就是价值又是重量. 于是这个问题便很好理解背包了. #];; ...

  9. mysql的root用户被删除, MySQL 服务无法启动 1067错误

    本文出现的问题有: 1, root(localhost) 用户被删除; 2, 在关闭mysql服务过后, 无法启动,出现1067错误; 我使用的mysql版本为5.6; mysql的安装路径: C:\ ...

  10. HBase Region的定位