hdu 1052 (greedy algorithm) 分类: hdoj 2015-06-18 16:49 35人阅读 评论(0) 收藏
thanks to
http://acm.hdu.edu.cn/discuss/problem/post/reply.php?action=support&postid=19638&messageid=1&deep=0
for the test case provided. below is an excerpt
data
8
11 9 8 8 8 4 3 2
11 8 8 8 8 4 3 2
answer
800
#include <cstdio>
#include <algorithm>
#define MAXSIZE 1002
int main() {
//freopen("input.txt","r",stdin);
int tian[MAXSIZE], king[MAXSIZE];
int nhorse,i,win,tie, tb,te,kb,ke;
while(scanf("%d",&nhorse)==1 && nhorse>0) {
for(i=0;i<nhorse;++i) scanf("%d",&tian[i]);
for(i=0;i<nhorse;++i) scanf("%d",&king[i]);
std::sort(tian,tian+nhorse,[](const int lhs, const int rhs) { return lhs>rhs; });
std::sort(king,king+nhorse,[](const int lhs, const int rhs) { return lhs>rhs; });
for(win=tie=0, tb=kb=0,te=ke=nhorse-1;tb<=te;) {
if(tian[tb]>king[kb]) { ++win; ++tb; ++kb; }
else if(tian[tb]<king[kb]) { --te; ++kb; }
else if(tian[te]>king[ke]) { ++win; --te; --ke; }
else {
if(tian[te]==king[kb]) ++tie;
--te; ++kb;
}
}
nhorse-=tie;
printf("%d\n",((win<<1)-nhorse)*200);
}
return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。// p.s. If in any way improment can be achieved, better performance or whatever, it will be well-appreciated to let me know, thanks in advance.
hdu 1052 (greedy algorithm) 分类: hdoj 2015-06-18 16:49 35人阅读 评论(0) 收藏的更多相关文章
- one recursive approach for 3, hdu 1016 (with an improved version) , permutations, N-Queens puzzle 分类: hdoj 2015-07-19 16:49 86人阅读 评论(0) 收藏
one recursive approach to solve hdu 1016, list all permutations, solve N-Queens puzzle. reference: t ...
- Hdu 1010 Tempter of the Bone 分类: Translation Mode 2014-08-04 16:11 82人阅读 评论(0) 收藏
Tempter of the Bone Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Othe ...
- Hdu 1009 FatMouse' Trade 分类: Translation Mode 2014-08-04 14:07 74人阅读 评论(0) 收藏
FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- HDU 1532 Drainage Ditches 分类: Brush Mode 2014-07-31 10:38 82人阅读 评论(0) 收藏
Drainage Ditches Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- Prime Path 分类: 搜索 POJ 2015-08-09 16:21 4人阅读 评论(0) 收藏
Prime Path Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 14091 Accepted: 7959 Descripti ...
- Removing Columns 分类: 贪心 CF 2015-08-08 16:10 10人阅读 评论(0) 收藏
Removing Columns time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...
- Hardwood Species 分类: POJ 树 2015-08-05 16:24 2人阅读 评论(0) 收藏
Hardwood Species Time Limit: 10000MS Memory Limit: 65536K Total Submissions: 20619 Accepted: 8083 De ...
- iOS自定义字体及类目 分类: ios技术 2015-05-15 16:34 195人阅读 评论(0) 收藏
1:获取字体文件 从各种渠道下载字体文件ttf, 网站或者从别的ipa里扣出来.(以fzltxh.ttf为例) 2:将fzltxh.ttf文件拷贝到工程中 3:在Info.plist中添加项: Fon ...
- 网站通用登录模块代码 分类: ASP.NET 2014-12-06 10:49 615人阅读 评论(0) 收藏
1.HTML部分: <form id="form1" runat="server"> <script src=".. ...
随机推荐
- 使用AppCan实现分享网站功能
使用AppCan实现分享网站功能 昨天我们实现了最基本的文字分享功能,今天呢,我们来实现基本的分享网站功能: 微信指引部分这里不再复述,具体请参见:http://newdocx.appcan.cn/i ...
- Yeoman自动构建js项目
Aug 19, 2013 Tags: bowergruntJavascriptjsnodejsyeomanyo Comments: 10 Comments Yeoman自动构建js项目 从零开始nod ...
- Signalr简单例子
一.需要引用的 Js: 二.编码 用的是signalr2,需要新建Startup.cs类,编码如下: using Microsoft.Owin; using Owin; using System; u ...
- android 内存处理工具
1. LeakCanary 检查内存泄露 LeakCanary 是一个开源的在debug版本中检测内存泄漏的java库. 让我们来看看一个cait的例子: 1 2 3 4 5 6 7 8 9 10 1 ...
- vs2013-tfs-疑问之版本控制器路径有双引号解决办法
问题描述: 最近项目:“****”展示交易平台 ,所以版本控制器路径为: 导致生成解决方案提示:路径有问题 解决办法: 1.直接在版本控制器重命名是不支持的,需要安装: Visual Studio ...
- (1) 深入理解Java虚拟机到底是什么?
好文转载:http://blog.csdn.net/zhangjg_blog/article/details/20380971 什么是Java虚拟机 作为一个Java程序员,我们每天都在写Java ...
- Android 进阶Android 中的 IOC 框架 【ViewInject】 (上)
1.概述 首先我们来吹吹牛,什么叫IoC,控制反转(Inversion of Control,英文缩写为IoC),什么意思呢? 就是你一个类里面需要用到很多个成员变量,传统的写法,你要用这些成员变量, ...
- Python3基础 print 查看一个列表中存储的所有内容
镇场诗:---大梦谁觉,水月中建博客.百千磨难,才知世事无常.---今持佛语,技术无量愿学.愿尽所学,铸一良心博客.------------------------------------------ ...
- 第 十一 天 Flagmeng 和动画
1.flagment 的使用,生命周期. 传递数据. 2. 基本动画的使用. 3. 对话框的使用. 4.样式和主题.
- java内部类以及匿名类
内部类 一个类内部定义的类称为内部类. 内部类允许把逻辑相关的类组织在一起,并控制内部代码的可视性. 内部类与外部类的结构层次如下. 顶层类:最外层的类 外部类:内部类所在的类 内部类:类内部定义的类 ...