Assignments
Assignments |
| Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) |
| Total Submission(s): 85 Accepted Submission(s): 65 |
|
Problem Description
In a factory, there are N workers to finish two types of tasks (A and B). Each type has N tasks. Each task of type A needs xi time to finish, and each task of type B needs yj time to finish, now, you, as the boss of the factory, need to make an assignment, which makes sure that every worker could get two tasks, one in type A and one in type B, and, what's more, every worker should have task to work with and every task has to be assigned. However, you need to pay extra money to workers who work over the standard working hours, according to the company's rule. The calculation method is described as follow: if someone’ working hour t is more than the standard working hour T, you should pay t-T to him. As a thrifty boss, you want know the minimum total of overtime pay.
|
|
Input
There are multiple test cases, in each test case there are 3 lines. First line there are two positive Integers, N (N<=1000) and T (T<=1000), indicating N workers, N task-A and N task-B, standard working hour T. Each of the next two lines has N positive Integers; the first line indicates the needed time for task A1, A2…An (Ai<=1000), and the second line is for B1, B2…Bn (Bi<=1000).
|
|
Output
For each test case output the minimum Overtime wages by an integer in one line.
|
|
Sample Input
2 5 |
|
Sample Output
4 |
|
Source
2010 Asia Regional Harbin
|
|
Recommend
lcy
|
/*
题意:有n个工作a,需要xi时间来完成,n个工作b,需要yi时间来完成,每天要有工人
来做工作a,b如果a,b的时间超过T,那么就要支付工人超出时长的额外金币,问最少
支付工人多少额外的金币。
初步思路:贪心一下,a从小到大排序,b从大到小排序,然后贪
*/
#include<bits/stdc++.h>
#define N 1100
using namespace std;
bool cmp1(int a,int b){
return a>b;
}
bool cmp2(int a,int b){
return a<b;
}
int n,t;
int a[N],b[N];
int main(){
freopen("in.txt","r",stdin);
while(scanf("%d%d",&n,&t)!=EOF){
for(int i=;i<n;i++)
scanf("%d",&a[i]);
for(int i=;i<n;i++)
scanf("%d",&b[i]);
sort(a,a+n,cmp1);
sort(b,b+n,cmp2);
int cur=;
for(int i=;i<n;i++){
if(a[i]+b[i]>t){
cur+=a[i]+b[i]-t;
}
}
printf("%d\n",cur);
}
return ;
}
Assignments的更多相关文章
- hdu 3661 Assignments (贪心)
Assignments Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- Sequence Assignments FRM-41830: List of Value contains no entries.
SYMPTOMS ============================================================ GL > Setup > Financials ...
- Assignments 1
跑了一下之前写的UiPath Assignments脚本,没什么问题,发上来供大家参考. 先看结果: github:https://github.com/WendyZheng1022/RPA 有时间我 ...
- 课程四(Convolutional Neural Networks),第四 周(Special applications: Face recognition & Neural style transfer) —— 3.Programming assignments:Face Recognition for the Happy House
Face Recognition for the Happy House Welcome to the first assignment of week 4! Here you will build ...
- 课程四(Convolutional Neural Networks),第一周(Foundations of Convolutional Neural Networks) —— 3.Programming assignments:Convolutional Model: application
Convolutional Neural Networks: Application Welcome to Course 4's second assignment! In this notebook ...
- verilog behavioral modeling --procedural assignments
1.procedural assignments are used for updating reg ,integer , time ,real,realtime and memory data ty ...
- CS231n -Assignments 1 Q1 and Q2
前言 最近在youtube 上学习CS231n的课程,并尝试完成Assgnments,收获很多,这里记录下过程和结果以及过程中遇到的问题,我并不是只是完成需要补充的代码段,对于自己不熟悉的没用过的库函 ...
- 论文解读(GRCCA)《 Graph Representation Learning via Contrasting Cluster Assignments》
论文信息 论文标题:Graph Representation Learning via Contrasting Cluster Assignments论文作者:Chun-Yang Zhang, Hon ...
- 【计算机网络】Stanford CS144 Lab Assignments 学习笔记
本文为我的斯坦福计算机网络课的编程实验(Lab Assignments)的学习总结.课程全称:CS 144: Introduction to Computer Networking. 事情发生于我读了 ...
随机推荐
- PHP防SQL注入攻击
PHP防SQL注入攻击 收藏 没有太多的过滤,主要是针对php和mysql的组合. 一般性的防注入,只要使用php的 addslashes 函数就可以了. 以下是一段copy来的代码: PHP代码 $ ...
- 西邮linux兴趣小组2014纳新免试题(三)
[第三关] 题目 http://sortsth.sinaapp.com/ 分析 查看网页源码,得知题目让找出6种排序算法,每次刷新或提交序列都变化. 15种算法清单: CountingSort ...
- NameError: name 'messagebox' is not defined 错误处理
写了段代码,想在按下button的时候跳个提示框出来,调试的时候提示了messagebox未定义 from tkinter import * def test_show(): messagebox.s ...
- 如何解决conda install:command not found问题
每次运行conda相关代码之前先做一遍source ~/.bashrc.即可
- 利用百度地图WEB服务APIGeoCoding API批量地址解析
Geocoding API包括地址解析和逆地址解析功能: 地理编码:即地址解析,由详细到街道的结构化地址得到百度经纬度信息,例如:“北京市海淀区中关村南大街27号”地址解析的结果是“lng:116.3 ...
- Python之scrapy安装
1.按照网上教程一步步实验,运行时报错: 'HtmlResponse' object has no attribute 'xpath' in scrapy 个人使用的是scrapy0.14.4,搜索得 ...
- python web框架之Tornado
说Tornado之前分享几个前端不错的网站: -- Bootstrap http://www.bootcss.com/ -- Font Awesome http://fontawesome.io/ - ...
- Oracle虚拟机VirtualBox安装成功后的注意事项
首先VirtualBox的安装教程 (1)按文档安装 (2)安装完之后配置共享文件夹 (3)安装windowxp镜像 (4)安装Oracle 详情请见Oracle安装文档 (5)启动xp虚拟机 (6 ...
- Django创建通用视图函数
想在我们有两个视图: def thinkingview(request): user = request.user if request.method == 'GET': return render( ...
- Django REST FrameWork中文教程2:请求和响应
从这一点开始,我们将真正开始覆盖REST框架的核心.我们来介绍几个基本的构建块. 请求对象REST框架引入了Request扩展常规的对象HttpRequest,并提供更灵活的请求解析.Request对 ...