十九届 浙大 校赛 A题 Thanks, TuSimple!
题目链接:
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5969
Thanks, TuSimple!
Time Limit: 1 Second Memory Limit: 65536 KB
In the very first sentence of the very first problem, we would like to give our sincere thanks to TuSimple, the sponsor of this contest.
Founded in 2015, TuSimple is a global autonomous trucking solution company headquartered in San Diego, operating self-driving trucks out of Tucson, Arizona. TuSimple is now developing a commercial-ready Level 4 (SAE) fully-autonomous driving solution for the logistics industry. TuSimple's trucks are the first and only capable of self-driving from depot-to-depot and do so every day for its customers. The company is driven by a mission to increase safety, decrease transportation costs, and reduce carbon emissions.
Nowadays, the trucking industry is currently facing a shortage of 50000 drivers (which is expected to increase to 175000 by the end of 2024) and is approaching a 100 percent turnover rate per year with an average driver age of 49 years old. According to a PwC study, autonomous trucking technologies will reduce annual operating costs for a traditional average long-haul truck by 28 percent in 2025. TuSimple is aiming to transform the 740-billion U.S. trucking industry by cutting costs, reducing carbon emissions and eradicating some of the challenges currently faced by operators.
Building the industry's first 1000-meter perception system, TuSimple soon becomes the pioneer in the industry. As is known to us, 1000 meters can provide 35 seconds of reaction time on average at highway speeds, enabling the system to make the safest and most efficient driving decisions. Even in the adverse weather conditions, the perception system is still designed to identify objects and obstacles, ensuring the safety of both cargoes, trucks, and passers-by. On the other hand, TuSimple's latest proprietary AI is now capable of long-distance highway driving and complex surface street driving, which allows fully autonomous deliveries from one depot to another.
Despite their advanced technology and an enormous sense of mission in the industry, TuSimple shares the corporate culture of honesty, realistic, exploration and innovation among their employees from bottom to top, which allows them to attract more and more elites from all expertise to join and get involved. "Here's why a little-known autonomous trucking company is beating Tesla and Waymo in the race for driverless big rigs", commented by Business Insider.
The future of trucking is now!As a manager of TuSimple, you are going to hold a dancing party for both the Development Department and the Marketing Department. There will be gentlemen and ladies in total and they are going to dance in pairs. After a careful investigation, we have already known that for each person, they like to dance with either a taller person or a person with smaller height. To simplify the problem, there are no two persons of the same height and people are only allowed to dance with a person of the opposite gender. In order to reserve a proper dancing field, you must calculate the maximum possible number of pairs of people dancing at the same time.
Input
There are multiple test cases. The first line of the input contains an integer , indicating the number of test cases. For each test case:
The first line contains two integers (), indicating the number of gentlemen and ladies.
The second line contains integers (, for all ), indicating the height of each gentleman.
The third line contains integers (, for all ), indicating the height of each lady.
The fourth line contains integers (), indicating the preference of each gentleman. If , it means gentleman prefers to dance with a lady of smaller height. Otherwise it indicates he prefers to have a taller dancing partner.
The fifth line contains integers (), indicating the preference of each lady. If , it means lady prefers to dance with a gentleman of smaller height. Otherwise it indicates she prefers to have a taller dancing partner.
It's guaranteed that the sum of and of all test cases will not exceed and for all .
Output
For each test case output one line containing one integer, indicating the answer.
Sample Input
1 3 3 1 2 5 3 4 6 1 1 0 0 0 1Sample Output
2Hint
In the sample test case, the 1st gentleman can dance with the 2nd lady, and the 2nd gentleman can dance with the 1st lady.
Submit Status
Copyright @ 2001-2019, Zhejiang University ACM/ICPC Team, All rights reserved.
题目大意:
T组数据
每组数据n个男生,m个女生
接下来两行分别是男生和女生的身高
接下来两行分别是表明对应的的男生想找一个比自己高的异性还是比自己矮的异性,0表示异性比自己矮,1表示异性比自己高
思路
这个题目不是最大匹配,时间超了
真正的思路:贪心,往死里贪。
将男生女生的按照身高和选择异性的标准排序,然后男生找矮的和女生找高的的匹配,女生找d矮的和男生找高的匹配
最后的结果就是答案。
O(n)的算法
This is the codes:
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<set>
#include<vector>
using namespace std;
#define PI acos(-1.0)
#define pppp cout<<endl;
#define EPS 1e-8
#define LL long long
#define ULL unsigned long long //1844674407370955161
#define INT_INF 0x3f3f3f3f //1061109567
#define LL_INF 0x3f3f3f3f3f3f3f3f //4557430888798830399
// ios::sync_with_stdio(false);
// 那么cin, 就不能跟C的 scanf,sscanf, getchar, fgets之类的一起使用了。
const int dr[]= {0, 0, -1, 1, -1, -1, 1, 1};
const int dc[]= {-1, 1, 0, 0, -1, 1, -1, 1};
int read()//输入外挂
{int ret=0, flag=0;char ch;if((ch=getchar())=='-')flag=1;else if(ch>='0'&&ch<='9')ret = ch - '0';while((ch=getchar())>='0'&&ch<='9')ret=ret*10+(ch-'0');return flag ? -ret : ret;
}
const int maxn=100050;
struct node
{int heigh;int select;
} a[maxn],b[maxn];
bool cmp(node x,node y) //排序,现把0放在前面,1放在后面
{if(x.select==y.select)return x.heigh<y.heigh;elsex.select<y.select;
}
int main()
{int T;scanf("%d",&T);while(T--){int n,m;scanf("%d%d",&n,&m); //全部初始化为未匹配点for(int i=0; i<n; ++i)scanf("%d",&a[i].heigh);for(int i=0; i<m; ++i)scanf("%d",&b[i].heigh);int cnt1=0;//男生0的个数int cnt2=0;//女生0的个数for(int i=0; i<n; ++i){scanf("%d",&a[i].select);if(!a[i].select)++cnt1;}for(int i=0; i<m; ++i){scanf("%d",&b[i].select);if(!b[i].select)++cnt2;}sort(a,a+n,cmp);sort(b,b+m,cmp);int num=0;int j=cnt2;for(int i=0; i<cnt1; ++i) //男生高,女生矮{if(a[i].heigh>b[j].heigh){num++;j++;}if(j>=m)break;}j=cnt1;for(int i=0; i<cnt2; ++i) //女生高,男生矮{if(b[i].heigh>a[j].heigh){num++;j++;}if(j>=n)break;}printf("%d\n",num);}return 0;
}
十九届 浙大 校赛 A题 Thanks, TuSimple!相关推荐
- 武理校赛A题 ljw的剥削(思维 + map应用)
武理校赛A题 ljw的剥削(思维 + map应用) 牛客链接 题意: 给定 a[],b[] 两个长度同为 n 的数组,经过一系列操作后, 使 p = ∑ i = 1 n m a x ( ( a i − ...
- 埃森哲杯第十六届上海大学程序设计联赛春季赛暨上海高校金马五校赛E题小Y吃苹果
链接:https://www.nowcoder.com/acm/contest/91/E 题意: 小Y买了很多苹果,但他很贪吃,过了几天一下就吃剩一只了.每一天小Y会数出自己的苹果个数X,如果X是偶数 ...
- 埃森哲杯第十六届上海大学程序设计联赛春季赛暨上海高校金马五校赛H题小Y与多米诺骨牌(线段树优化dp)
题意 题目链接:https://www.nowcoder.com/acm/contest/91/H 来源:牛客网 题解 设l[i]l[i]l[i]为向左推第iii个骨牌最远能影响到的骨牌的编号,r[i ...
- 埃森哲杯第十六届上海大学程序设计联赛春季赛暨上海高校金马五校赛A题Wasserstein Distance
题目链接:https://www.nowcoder.com/acm/contest/91/A 题意:给两组数据,求把A变成B状态需花费的最小体力. 思路:s=s+abs(a[i]-b[i]);a[i+ ...
- Little Sub and Piggybank (杭师大第十二届校赛G题) DP
题目传送门 题意:每天能往存钱罐加任意实数的钱,每天不能多于起那一天放的钱数.如果某一天的钱数恰好等于那天的特价商品,则可以买,求最后的最大快乐值. 思路:先来一段来自出题人的题解: 显然的贪心:如果 ...
- 2019河南省第十二届ACM省赛原题题目及省赛榜单
题目 榜单 Rank Name Solved Time A B C D E F G H I J Total att/so ...
- SDUT 校赛 D题 魔戒(bfs+四维数组)
魔戒 Time Limit: 1000MS Memory Limit: 65536KB Problem Description 蓝色空间号和万有引力号进入了四维水洼,发现了四维物体--魔戒. 这里我 ...
- QAU 18校赛 J题 天平(01背包 判断能否装满)
问题 J: 天平 时间限制: 1 Sec 内存限制: 128 MB 提交: 36 解决: 9 [提交][状态][讨论版][命题人:admin] 题目描述 天平的右端放着一件重量为w的物品.现在有n ...
- 广工十四届校赛 count 矩阵快速幂
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6470 题意:求,直接矩阵快速幂得f(n)即可 构造矩阵如下: n^3是肯定得变换的,用二项式展开来一点 ...
最新文章
- Matlab与线性代数 -- 矩阵的大小
- throws和throw抛出异常的使用规则
- python mysql模块 pip_MySQLpython模块不能与Pip一起在windows中安装
- node 生成随机头像_唯一ID生成算法剖析
- 单核工作法16:循序渐进(下)
- No new data sinks have been defined since the last execution.
- SAP UI5 Currency 数据类型的校验逻辑分析
- Typecho开启全站Pjax
- 解决svn cannot set LC_CTYPE locale的问题
- python cv模块_Python cv包_程序模块 - PyPI - Python中文网
- RedisTemplate清空所有键值对
- 数据系统架构-3.数据仓库设计
- 1人30天44587行代码,分享舍得网开发过程
- Python3自定义包
- Ubuntu 开机自动开启数字键小键盘
- 缠论三大套利技术模型
- java 取一个数的各个位数
- 【第七章】 C语言之牛客网力扣刷题笔记 【点进来保证让知识充实你一整天】
- 图表色彩运用原理的全面解析
- 2023年国家司法考试报名条件有哪些 非法学可以考吗