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) 收藏的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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) ...

  4. 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) ...

  5. Prime Path 分类: 搜索 POJ 2015-08-09 16:21 4人阅读 评论(0) 收藏

    Prime Path Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 14091 Accepted: 7959 Descripti ...

  6. 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 ...

  7. Hardwood Species 分类: POJ 树 2015-08-05 16:24 2人阅读 评论(0) 收藏

    Hardwood Species Time Limit: 10000MS Memory Limit: 65536K Total Submissions: 20619 Accepted: 8083 De ...

  8. iOS自定义字体及类目 分类: ios技术 2015-05-15 16:34 195人阅读 评论(0) 收藏

    1:获取字体文件 从各种渠道下载字体文件ttf, 网站或者从别的ipa里扣出来.(以fzltxh.ttf为例) 2:将fzltxh.ttf文件拷贝到工程中 3:在Info.plist中添加项: Fon ...

  9. 网站通用登录模块代码 分类: ASP.NET 2014-12-06 10:49 615人阅读 评论(0) 收藏

    1.HTML部分:     <form id="form1" runat="server">     <script src=".. ...

随机推荐

  1. Python 时间和日期模块的常用例子

    获取当前时间的两种方法 import datetime,time now = time.strftime("%Y-%m-%d %H:%M:%S") print now now = ...

  2. android混合开发,webview的java与js互操作

    android原生应用,用webview加载应用中的网页,并且java代码与js代码可以互相操作. 这是混合开发的基石,最基本也最重要的东西,实验代码在这里. 概括说说—— java调js:调用web ...

  3. python核心编程学习记录之映射和集合类型

    字典是python里唯一的映射类型

  4. oracle mysql sqlserver数据库中的分页

    oracle: select * from (select rownum r,t1.* from tablename t1 where rownum <M+N ) t2 where t2.r&g ...

  5. JAVA生成图片缩略图、JAVA截取图片局部内容

    package com.ares.image.test; import java.awt.Color; import java.awt.Graphics; import java.awt.Image; ...

  6. DAO

    DAO Data Access Object DAO(Data Access Object)是一个数据访问接口,数据访问:顾名思义就是与数据库打交道. 夹在业务逻辑与数据库资源中间. DAO模式是标准 ...

  7. [转](五)unity4.6Ugui中文教程文档-------概要-UGUI Interaction Components

    大家好,我是孙广东.   转载请注明出处:http://write.blog.csdn.net/postedit/38922399 更全的内容请看我的游戏蛮牛地址:http://www.unityma ...

  8. 【转载】详解CreateProcess调用内核创建进程的过程

    原文:详解CreateProcess调用内核创建进程的过程 昨天同学接到了腾讯的电面,有一题问到了CreateProcess创建进程的具体实现过程,他答得不怎么好吧应该是, 为了以防万一,也为了深入学 ...

  9. How can I view currently running MySQL queries?( 查看正在运行的MySQL语句/脚本命令)

    show processlist;show processlist\G;SHOW FULL PROCESSLIST;SHOW FULL PROCESSLIST\G; REF:http://dev.my ...

  10. php 判断是手机版还是电脑端

    function isMobile() { // 如果有HTTP_X_WAP_PROFILE则一定是移动设备 if (isset ($_SERVER['HTTP_X_WAP_PROFILE'])) { ...