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. 事情发生于我读了 ...
随机推荐
- Oracle DBA 常用查询
1. 查询系统所有对象 select owner, object_name, object_type, created, last_ddl_time, timestamp, statusfrom db ...
- Oculus关于Internal Error:OVR53225466报错解决方法
安装Oculus过程中可能会出现Internal Error:OVR53225466报错提示,如附件所示: 解决方法:修改hosts文件 操作方法: (1)以管理员方式打开记事本: (2)打开C:\W ...
- TETeLasr Cutting System 开机回零问题
TETeLasr Cutting System 开机回零问题 :打开 "轴信息" :打开 加工参数-->机器参数-->脉冲当量: X轴==4000 Y轴== ...
- [mysql] ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES).
用mysql -u root -p显示ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YE ...
- Delphi10.2 VCL Forms Application 的构成
Delphi10.2 项目的构成(File Extensions of Files Generated by RAD Studio) Step1.打开 Delphi10.2,选择[File | New ...
- Huge Mission
Huge Mission Problem Description Oaiei is busy working with his graduation design recently. If he ca ...
- 移动APP测试方法总结
移动APP测试,除了基础功能测试测试方法外,需要额外关注以下方面: 兼容性测试 流量测试 电量测试 弱网络测试 稳定性测试 安全测试 环境相关测试 兼容性测试 针对App通常会考虑这些方面: 1.操作 ...
- 一张图理清ASP.NET Core启动流程
1. 引言 对于ASP.NET Core应用程序来说,我们要记住非常重要的一点是:其本质上是一个独立的控制台应用,它并不是必需在IIS内部托管且并不需要IIS来启动运行(而这正是ASP.NET Cor ...
- PHP程序员40点陋习
1.不写注释 2.不使用可以提高生产效率的IDE工具 3.不使用版本控制 4.不按照编程规范写代码 5.不使用统一的方法 6.编码前不去思考和计划 7.在执行sql前不执行编码和安全检测 8.不使用测 ...
- PHP字符串替换str_replace()函数4种用法详解
mixed str_replace ( mixed $search , mixed $replace , mixed $subject [, int &$count ] )该函数返回一个字符串 ...