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匹马 ...
随机推荐
- vue中使用axios
1.结合vue-axios使用 vue-axios是按照vue插件的方式去写的,那么结合vue-axios就可以使用Vue.use()这个方法import axios from 'axios' imp ...
- opencv的安装
网上搜了好多文章安装opencv3.2.0都未能成功,写的也个不相同,后来找到了opencv官网的教程,看了后才发现,这上面才是最详细的. 于是按照opencv官网教程安装,安装的一半就中断了.经过苦 ...
- php常用字符串方法
chop() 移除字符串右侧的空白字符或其他字符 ltrim() 移除字符串左侧的空白字符或其他字符 rtrim() 移除字符串右侧的空白字符或其他字符 tr ...
- tp5 数据库
连接数据库: 在config下面的database.php里. 查找数据: halt(Db::name('studys')->column('name','age')); 也可以用find fi ...
- maven 不能使用 snapshot 的解决方式
最近项目需要用到snapshot的包来进行构建过程,但是怎么都下不了构建的snapshot包.查询了相关资料,发现网上的资料不全,特总结下: 我使用的是nexus来作为代理中央库proxy. 检查步骤 ...
- java上传文件获取跟目录的办法
在java中获得文件的路径在我们做上传文件操作时是不可避免的.web 上运行1:this.getClass().getClassLoader().getResource("/"). ...
- Djangoの1
有ip无路由是404,ip也无是无法访问此网站.url中?前的是路由,?后是GET请求的各组参数. 子项目和子应用下的两类urls.py:[]内的各个路由函数url,其首参网址的开头无/,结尾有/ ...
- vue数据更新UI不刷新显示解决方案
vue比较常见的坑就是数据(后台返回)更新了,但是UI界面并没有更新,常见于以下情况: 一.数据为数组时1.通过数组索引修改数组元素例如: 此时UI数据并不会刷新 2.修改数组长度时: 解决方案: 如 ...
- 分析Ajax抓取今日头条街拍美图
spider.py # -*- coding:utf-8 -*- from urllib import urlencode import requests from requests.exceptio ...
- Python编程练习:使用 turtle 库完成玫瑰花的绘制
绘制效果: 源代码: import turtle # 设置初始位置 turtle.penup() turtle.left(90) turtle.fd(200) turtle.pendown() tur ...