Description

题目链接

Solution

这题就是一个贪心,

如果最弱的能赢对方最弱的就赢

否则最强的能赢对面最强的就赢

否则最弱的换对面最强

Code

#include <cstdio>
#include <algorithm>
using namespace std; int n,Ans,A[100010],B[100010]; inline int read(){
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
} void solve(int f){
Ans=0;
int la=1,ra=n,lb=1,rb=n;
while(la<=ra&&lb<=rb){
if(A[la]>B[lb]) Ans+=2,la++,lb++;
else if(A[ra]>B[rb]) Ans+=2,ra--,rb--;
else{
if(A[la]==B[rb]) Ans++;
la++,rb--;
}
}
if(!f)swap(A,B),printf("%d ",Ans);
else printf("%d\n",2*n-Ans);
} int main(){
n=read();
for(int i=1;i<=n;++i)A[i]=read();
for(int i=1;i<=n;++i)B[i]=read();
sort(A+1,A+n+1);sort(B+1,B+n+1);
solve(0);solve(1);
return 0;
}

最新文章

  1. Http协议相关内容
  2. nodejs开发 express路由与中间件
  3. AsyncTask异步任务类使用学习
  4. Windows Server 2008修改IE浏览器级别便于使用
  5. 命名空间 - PHP笔记
  6. HTML meta viewport属性说明(mark)
  7. 单据类型BE构建
  8. C++学习笔记一 —— 两个类文件互相引用的处理情况
  9. 『TCP/IP详解——卷一:协议』读书笔记——03
  10. RAII惯用法详解
  11. 几个经常用到的字符串的截取(java)
  12. C#App.config的使用
  13. 从尾到头打印链表--《剑指offer》
  14. PHP学习笔记 01 之表单传值
  15. from、where、group、with、having、order、union、limit 的使用
  16. php中的session过期思考一二
  17. P1096(简单dp)
  18. Fast Failure Detection and Recovery in SDN with Stateful Data Plane
  19. RedHat 简易配置 VNC Server 与VNC View详细说明
  20. K8S镜像删除及环境清理

热门文章

  1. MySQL慢查询分析工具pt-query-digest详解
  2. Eclipse JSP 页面设置 charset=UTF-8
  3. 关于在Share point 2010 中保存SPFieldLookupValue类型到一个List中的问题
  4. Linux命令之创建文件夹3
  5. org.springframework.beans.factory.BeanNotOfRequiredTypeException
  6. bootstrap-table 大量字段整体表单上传之时间处理
  7. 水晶报表分组,统计,求和,sum()函数使用
  8. iOS设置竖屏,播放视频可以任性旋转的解决方法,亲测可用
  9. CRM和C4C product category hierarchy的可编辑性控制逻辑
  10. SAP成都C4C小李探花:浅谈Fiori Design Guidelines