hdu 1052 田忌赛马
贪心,排序从大到小。。
先比大的。跑只是就拿最小的来送死。。
,
假设是平局就比后面的。。。
若后面也是平局就拿去跟前面的去跑。
。。
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
int s[1005],w[1005];
int main()
{
int n,i;
while(scanf("%d",&n))
{
if(n==0)
break;
for(i=0;i<n;i++)
scanf("%d",&w[i]);
for(i=0;i<n;i++)
scanf("%d",&s[i]);
sort(w,w+n);
sort(s,s+n);
int z=0,sum=0,c=n-1,v=n-1;
int i1=0,i2=0;
while(z++<n)
{
if(w[c]>s[v])
{
sum+=200;
c--;
v--;
}
else if(w[c]<s[v])
{
sum-=200;
i1++;
v--;
}
else
{
if(w[i1]>s[i2])
{
sum+=200;
i1++;
i2++;
}
else
{
if(w[i1]<s[v])
sum-=200;
i1++;
v--;
}
}
}
printf("%d\n",sum);
}
return 0;
}
最新文章
- XF custom render 各平台实现类
- CSS3基础03(3D②) 求粉丝
- LintCode ";Coins in a Line III"; !!
- Android学习笔记(1)
- 如何将EXCEL表导入MYSQL
- JSON转Model内部实现解析
- 【bzoj3998】 TJOI2015—弦论
- 非阻塞式线程安全列表-ConcurrentLinkedDeque
- Vuex 最简单的数量增减实例
- 一些有用的Java参考资料
- html标题-段落-字符实体-换行
- 【PAT】B1041 考试座位号(15 分)
- Pool多进程示例
- 利用tablespace特性将数据库移动到新磁盘
- 银行卡所属公司判断 参考自https://blog.csdn.net/well2049/article/details/79429130
- Linux - 磁盘操作
- MAX_STATEMENT_TIME uses confusing syntax
- vue 的 生命周期
- bzoj 3277 &; bzoj 3473,bzoj 2780 —— 广义后缀自动机
- Find command usage in Linux with excellent examples--reference
热门文章
- 2.vector数组
- 用Navicat连接MySQL数据库出现1251错误:密码方式错误
- linux网络防火墙-iptables基础详解
- 疯狂html5讲义(二):HTML5简的经常使用元素与属性(二):html5新增的通用属性
- Rdis-主从复制
- Java exception handling best practices--转载
- 二叉树的递归插入【Java实现】
- IDEA配置svn地址方法及出现的问题的解决办法
- 16、cgminer学习之:popen函数和system函数详解(执行系统命令)
- 【Codeforces Round #431 (Div. 2) C】From Y to Y