codechef AUG17 T3 Greedy Candidates
Greedy Candidates Problem Code: GCAC
The placements/recruitment season is going on in various colleges. The interviews are over, and each company has selected some students. But since each student can end up finally in at most one company, a student might have to reject a company which selected him. The companies know this, and hence, the companies usually select more students than it can actually employ. So now, the exact pairings should be done. We talk about one such session in a famous college.
There are a total of N candidates (numbered from 1 to N) and M companies (numbered from 1 to M) taking part in it. Each candidate has a certain minimum expectation of salary, which is given by the array minSalary (All the arrays are 1-indexed). For each candidate, you are also given the information regarding the companies which have selected him. This information is given by an array qual of sizeN * M, where qual[i][j] = 1 if and only if the i-th candidate has qualified for a job in the j-th company. A company will provide a fixed salary to the candidates it employs, which is given by the array offeredSalary. Also, a company has an upper bound on the number of candidates it can employ and finally give an offer to. This information is provided by array maxJobOffers.
The D-day has come. Each candidate from 1, 2, .. N (in this order) will go to the placements coordinator. When the i-th student goes, among the companies which have selected him, and which still haven't reached their maxJobOffers limit, he picks the company which provides the maximum offeredSalary, provided that it is at least his minSalary.
You have to find the number of the candidates that will end up with a job, the total amount of salaries that the candidates will get, and the number of companies that won't be able to employ even a single candidate. This information is very crucial for the placement coordinator, so as to analyze whether it makes sense to invite a company to come to the placements session next year or not. Please help the coordinator!
Input
- The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows
- First line of each test case contains two space separated integer N, M.
- The next line contains N space separated integers denoting the array minSalary.
- Each of the next M lines contains two space separated integers denotingofferedSalary[i] and maxJobOffers[i].
- The next N lines will contain the description of the 2-D array qual. Each of the Nlines will contain M binary integers (without any space): j-th integer in the i-th line will denote qual[i][j].
Output
- For each test case, output three integers in a new line, denoting the number of the candidates that will get a job, the total amount of salaries that the candidates will get, and the number of companies that won't be able to hire even a single candidate.
Constraints
- 1 ≤ T ≤ 10
- 1 ≤ N, M ≤ 103
- 0 ≤ minSalary[i] ≤ 109
- 0 ≤ qual[i][j] ≤ 1
- 1 ≤ offeredSalary[i] ≤ 109
- 1 ≤ maxJobOffers[i] ≤ 106
- All elements of the array offeredSalary are distinct
Subtasks
- Subtask 1 (30 points): 1 ≤ N, M ≤ 200
- Subtask 2 (70 points): Original Constraints
Example
Input:
1
5 6
5000 10000 3000 20 100
10000 2
800 2
600 1
10 8
1000 9
2000 10
111111
100000
000000
000001
100100 Output:
3 22000 4
Explanation
There are 5 candidates and 6 companies.
The first candidate wants a job that pays at least 5000 Rs.
He has qualified in all the companies, so he will choose the 1st company that provides him the maximum money, 10000 Rs.
The second candidate will get a job offer of 10000 Rs from 1st company.
The third candidate has not qualified in any company, so he won't get any job.
The fourth candidate has qualified only in 6-th company which provides a salary of 2000 Rs
which is greater than or equal to 20, the minimum salary expected by the fourth candidate.
The fifth candidate wants minimum salary 100 Rs. He has qualified in company 1st and 4th.
The 1st company won't hire him as it has already filled the quota of hiring two people.
4th company is providing the candidate less than 100 Rs, so he won't join that too.
So, overall there are three candidates that got the job (first, second and fourth).
Total amount of salary is 10000 + 10000 + 2000 = 22000.
Only first and 6-th companies are able to select some candidates,
so there are 4 companies that are not able to hire any candidate. Hence, the answer will be 3 22000 4.
——————————————————————————————————————————————
这道题其实就是道模拟题 然而体面超级恶心QAQ
其实有n个人m个公司
n个人每个人有一个能接受的工资的底线
m个公司有能给出的工资以及应聘人数
给出一个矩阵表示人和公司之间是否有关系
然后就从第一个人开始贪心地选择大于等于他接受范围的工资里最大的
求能找到工作的人数 他们的工资总和 以及多少个公司一个人都没应聘到
codechef AUG17 T3 Greedy Candidates的更多相关文章
- codechef AUG17 T2 Chef and Mover
Chef and Mover Problem Code: CHEFMOVR Chef's dog Snuffles has so many things to play with! This time ...
- codechef AUG17 T1 Chef and Rainbow Array
Chef and Rainbow Array Problem Code: RAINBOWA Chef likes all arrays equally. But he likes some array ...
- codechef AUG17 T5 Chef And Fibonacci Array
Chef has an array A = (A1, A2, ..., AN), which has N integers in it initially. Chef found that for i ...
- codechef AUG17 T4 Palindromic Game
Palindromic Game Problem Code: PALINGAM There are two players A, B playing a game. Player A has a st ...
- codechef T3 计算器
CALC: 计算器题目描述 大厨有一个计算器,计算器上有两个屏幕和两个按钮.初始时每个屏幕上显示的都是 0.没按 一次第一个按钮,就会让第一个屏幕上显示的数字加 1,同时消耗 1 单位的能量. 每按一 ...
- [Optimization] Greedy method
Given two sequences of letters A and B, find if B is a subsequence of A in thesense that one can del ...
- codechef MAY18 div2 部分题解
T1 https://www.codechef.com/MAY18B/problems/RD19 刚开始zz了,其实很简单. 删除一个数不会使gcd变小,于是就只有0/1两种情况 T2 https:/ ...
- [Codechef - AASHRAM] Gaithonde Leaves Aashram - 线段树,DFS序
[Codechef - AASHRAM] Gaithonde Leaves Aashram Description 给出一棵树,树的"N"节点根植于节点1,每个节点'u'与权重a[ ...
- [Codechef - ADITREE] Adi and the Tree - 树链剖分,线段树
[Codechef - ADITREE] Adi and the Tree Description 树上每个节点有一个灯泡,开始所有灯泡都是熄灭的.每次操作给定两个数 \(a,b\) ,将 \(a,b ...
随机推荐
- ceph 性能
mysql在以下设备备份耗时,供大家参考: 备份文件大小 sata用时 ceph用时 nas挂载sata盘用时 7G 1分钟 15G 2分钟 21分钟 47G 8分钟 82分钟 274 ...
- TCP/IP与OSI参考模型原理
网络是很重要同时也是很难理解的知识,这篇文章将会用自己容易理解的方式来记录有关网络的tcp与osi模型内容,不求专业深刻,但求通俗易懂也好. OSI参考模型 OSI定义了网络互连的七层框架(物理层.数 ...
- MySQL的备份与恢复理解与备份策略
MySQL的备份主要分为逻辑备份和物理备份 逻辑备份 在MySQL中逻辑备份的最大优点是对各种存储引擎都可以用同样的方法来备份.而物理备份则不同,不同的存储引擎有着不同的备份方法.Mysql中的逻辑备 ...
- React学习记录二
环境基本弄清楚了以后,开始总会写个hello world什么的,开发做了这么久了,就跳过这一步吧. 还是从打开vscode说起吧,这里文件菜单打开一个文件夹Demos,查看菜单打开集成终端,也可以使用 ...
- 常用自写函数[更新ing]
int gcd (int x, int y)//最大公约数 { return y == 0 ? x : gcd( y , x % y ); } int lcm(int x, int y)//最小公倍数 ...
- SQLite3 of python
SQLite3 of python 一.SQLite3 数据库 SQLite3 可使用 sqlite3 模块与 Python 进行集成,一般 python 2.5 以上版本默认自带了sqlite3模块 ...
- [BZOJ1208]宠物收养所(Splay)
Description 最近,阿Q开了一间宠物收养所.收养所提供两种服务:收养被主人遗弃的宠物和让新的主人领养这些宠物.每个领养者都希望领养到自己满意的宠物,阿Q根据领养者的要求通过他自己发明的一个特 ...
- 华东交通大学2018年ACM“双基”程序设计竞赛 K
MIKU酱是个玩游戏氪金的人,游戏公司给她制定了新的规则,如果想从关卡i到关卡j,你需要交一些钱就可以了,但同时,MIKU酱的爸爸zjw很爱她,所以她可以每过一关就向她爸要一次钱,但她爸每次给他的钱是 ...
- 【palindrome partitioning II】cpp
题目: Given a string s, partition s such that every substring of the partition is a palindrome. Return ...
- 【Gray Code】cpp
题目: The gray code is a binary numeral system where two successive values differ in only one bit. Giv ...