#include<iostream>
#include<algorithm>
using namespace std;
bool cmp(const int,const int);
] = {};
] = {};
int main()
{
    int n;
    ){
        ,te = n-,ke = n-,kf = ,i;
        ;i<n;++i)cin>>tian[i];
        ;i<n;++i)cin>>king[i];
        sort(king,king+n,cmp);
        sort(tian,tian+n,cmp);
        ;
        ;
        while(tf<=te && kf<=ke){//
            if(tian[tf] > king[kf]){//最快的能跑过,赚钱
                tf++;kf++;cut +=;
            }else if(tian[tf] < king[kf]){//跑不过,最慢的兑子,亏200
                te--;kf++;cut -=;
            }else
            {//最快的相等,用最慢的兑子
                if(tian[te] > king [ke]){//最慢的能赚钱
                    ke--;te--;cut += ;
                }else{
                    ;//赚不了钱的兑子
                    te--;kf++;
                }
            }
        }
        cout<<cut<<endl;
    }
    ;
}
bool cmp(const int a,const int b){
    return a>b;
}

poj-2287---Tian Ji -- The Horse Racing的更多相关文章

  1. POJ 2287 Tian Ji -- The Horse Racing(贪心)

    题意:田忌和齐王有n匹马,进行n局比赛,每局比赛输者给胜者200,问田忌最多能得多少钱. 分析:如果田忌最下等的马比齐王最下等的马好,是没必要拿最下等的马和齐王最好的马比的.(最上等马同理) 因此,如 ...

  2. (贪心5.1.2)POJ 2287 Tian Ji -- The Horse Racing

    /* * POJ_2287.cpp * * Created on: 2013年10月9日 * Author: Administrator */ #include <iostream> #i ...

  3. 【OpenJ_Bailian - 2287】Tian Ji -- The Horse Racing (贪心)

    Tian Ji -- The Horse Racing 田忌赛马,还是English,要不是看题目,我都被原题整懵了,直接上Chinese吧 Descriptions: 田忌和齐王赛马,他们各有n匹马 ...

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

  5. Tian Ji -- The Horse Racing

    Tian Ji -- The Horse Racing Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Jav ...

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

  7. hdoj 1052 Tian Ji -- The Horse Racing【田忌赛马】 【贪心】

    思路:先按从小到大排序, 然后从最快的開始比(如果i, j 是最慢的一端, flag1, flag2是最快的一端 ),田的最快的大于king的 则比較,如果等于然后推断,有三种情况: 一:大于则比較, ...

  8. hdu1052 Tian Ji -- The Horse Racing 馋

    转载请注明出处:http://blog.csdn.net/u012860063 题目链接:pid=1052">http://acm.hdu.edu.cn/showproblem.php ...

  9. 杭州电 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 ...

  10. 【贪心】[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 ...

随机推荐

  1. Swift数组的存取与修改

    对数组的存取与修改可以通过数组的方法和属性来进行,或者使用数组的下标语法. 要知道数组中元素的数量,可以查看它的只读属性count: println("The shopping list c ...

  2. 【Android Developers Training】 49. 轻松录制视频

    注:本文翻译自Google官方的Android Developers Training文档,译者技术一般,由于喜爱安卓而产生了翻译的念头,纯属个人兴趣爱好. 原文链接:http://developer ...

  3. 1.如何使用vbs打开网页并且登陆

    例如自动打开繁星的网页并且登录 Private Sub CommandButton1_Click() Dim ie As Object Set ie = CreateObject("Inte ...

  4. if和for的应用

    语句 顺序 结束加分号 分支 让程序根据条件不同执行不同的代码 if语句 if(条件){代码} if(条件){代码}else{代码} else if(条件){代码} if嵌套 switch...cas ...

  5. vue2.0引入腾讯地图

    百度很多东西,然后我没找到腾讯地图在VUE2.0里面的引用.于是根据找的其他地图引用资料进行尝试.步骤如下. 首先在src里面建立了TMap.js的文件,内容如下: export function T ...

  6. 【SqlServer系列】表单查询

    1   概述 如下几个问题,如果你能解决,请继续往下看,若不能解决,请先复习SQL基础知识,再来阅读本篇文章.本篇文章深度中等左右. Q1:表StudentScores如下,用一条SQL语句查询出每门 ...

  7. Luogu 1559 运动员最佳匹配问题(带权二分图最大匹配)

    Luogu 1559 运动员最佳匹配问题(带权二分图最大匹配) Description 羽毛球队有男女运动员各n人.给定2 个n×n矩阵P和Q.P[i][j]是男运动员i和女运动员j配对组成混合双打的 ...

  8. IntentService与Service的区别

    IntentService是继承并处理异步请求的一个类,在IntentService内有一个工作线程来处理耗时操作,启动IntentService的方式和启动传统的Service一样,同时,当任务执行 ...

  9. 51nod_1384:全排列(STL)

    题目链接 记住next_permutation函数的用法,另外string在这里比char[]慢好多啊.. //#include<bits/stdc++.h> //using namesp ...

  10. ajax-post请求

    一般来说字符串读取不出来查看下面这行代码是否加上: xmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencode ...