ZOJ Problem Set - 2397 Tian Ji -- The Horse Racing
#include<iostream>
#include<cmath>
#include<algorithm>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
int a[],b[],n;
int main(){
while (cin>>n,n){
REP(i,n)cin>>a[i];
REP(i,n)cin>>b[i];
sort(a,a+n);
sort(b,b+n);
int ha=,ta=n-,hb=,tb=n-,ans=;
REP(i,n){
if (a[ha]>b[hb])ans++,ha++,hb++;
else if (a[ta]>b[tb])ans++,ta--,tb--;
else ans-=(a[ha]!=b[tb]),ha++,tb--;
}
cout<<ans*<<endl;
}
return ;
}
#define 用起来
ZOJ Problem Set - 2397 Tian Ji -- The Horse Racing的更多相关文章
- ZOJ 2397:Tian Ji -- The Horse Racing
Tian Ji -- The Horse Racing Time Limit: 5 Seconds Memory Limit: 32768 KB Here is a famous story ...
- Hdu 1052 Tian Ji -- The Horse Racing
Tian Ji -- The Horse Racing Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (J ...
- Tian Ji -- The Horse Racing
Tian Ji -- The Horse Racing Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Jav ...
- UVA 1344 Tian Ji -- The Horse Racing
Tian Ji -- The Horse Racing Here is a famous story in Chinese history. That was about 2300 years ago ...
- hdoj 1052 Tian Ji -- The Horse Racing【田忌赛马】 【贪心】
思路:先按从小到大排序, 然后从最快的開始比(如果i, j 是最慢的一端, flag1, flag2是最快的一端 ),田的最快的大于king的 则比較,如果等于然后推断,有三种情况: 一:大于则比較, ...
- hdu1052 Tian Ji -- The Horse Racing 馋
转载请注明出处:http://blog.csdn.net/u012860063 题目链接:pid=1052">http://acm.hdu.edu.cn/showproblem.php ...
- 杭州电 1052 Tian Ji -- The Horse Racing(贪婪)
http://acm.hdu.edu.cn/showproblem.php? pid=1052 Tian Ji -- The Horse Racing Time Limit: 2000/1000 MS ...
- 【贪心】[hdu1052]Tian Ji -- The Horse Racing(田忌赛马)[c++]
Tian Ji -- The Horse Racing Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java ...
- 【OpenJ_Bailian - 2287】Tian Ji -- The Horse Racing (贪心)
Tian Ji -- The Horse Racing 田忌赛马,还是English,要不是看题目,我都被原题整懵了,直接上Chinese吧 Descriptions: 田忌和齐王赛马,他们各有n匹马 ...
随机推荐
- freeType移植总结①——使用keil编译freeType2库
在各个技术博客搜索相关资料后,终于将freeType的源码用keil工程编译通过,这里记录一下步骤和遇到的问题. 因为网上的资料都是旧版本freeType的工程,这里博主使用的是freeType2.9 ...
- css 文本超出2行就隐藏并且显示省略号
overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-box-orient: vertical; -webk ...
- 【慕课网实战】二、以慕课网日志分析为例 进入大数据 Spark SQL 的世界
MapReduce的局限性: 1)代码繁琐: 2)只能够支持map和reduce方法: 3)执行效率低下: 4)不适合迭代多次.交互式.流式的处理: 框架多样化: 1)批处理(离线):MapRed ...
- Python学习过程中各个难点---数据类型篇
---恢复内容开始--- 当时在学习python的基本数据类型时,对于可变与不可变类型不是了解的很透彻,这篇是回过头来自己的一些理解. 可变的数据类型有列表,不可变的数据类型有字符串,数字和元组 ...
- Sql- Group By ,Where,having用法
Group by,where,having 是数据库查询中最常用的几个关键字.在工作中,时常用到,前面遇到一个问题,一个查询中使用了where ,group by ,having及聚集函数时 ,执行顺 ...
- Scala知识点汇总
Scala数组小结 1.定长数组 定长数组:指长度不可变的数组Array.第一种方式:先声明一个数组,后初始化该数组: scala> val array = new Array[Double]( ...
- 《python语言程序设计》_第二章编程题
2.1 程序: Celsius=eval(input("Enter a degree in Celsius:"))#输入摄氏度的值Celsiusfahrenheit =(9/5)* ...
- CSS+DIV布局中absolute和relative区别
原文:http://developer.51cto.com/art/201009/225201.htm 这里向大家简单介绍一下CSS+DIV布局中absolute和relative属性的用法和区别,定 ...
- #224 Profile Lookup (for in & if )
我们有一个对象数组,里面存储着通讯录. 函数 lookUp 有两个预定义参数:firstName值和prop属性 . 函数将会检查通讯录中是否存在一个与传入的 firstName 相同的联系人.如果存 ...
- 关于oracle数据库的小知识
--查询语句:select 列名/通配符/列别名/表达式 from 表名 (修饰/限制语句)select * from tab;select tname from tab;--指定的列select t ...