贪心,排序从大到小。。

先比大的。跑只是就拿最小的来送死。。

假设是平局就比后面的。。。

若后面也是平局就拿去跟前面的去跑。

。。

#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;

}

最新文章

  1. XF custom render 各平台实现类
  2. CSS3基础03(3D②) 求粉丝
  3. LintCode &quot;Coins in a Line III&quot; !!
  4. Android学习笔记(1)
  5. 如何将EXCEL表导入MYSQL
  6. JSON转Model内部实现解析
  7. 【bzoj3998】 TJOI2015—弦论
  8. 非阻塞式线程安全列表-ConcurrentLinkedDeque
  9. Vuex 最简单的数量增减实例
  10. 一些有用的Java参考资料
  11. html标题-段落-字符实体-换行
  12. 【PAT】B1041 考试座位号(15 分)
  13. Pool多进程示例
  14. 利用tablespace特性将数据库移动到新磁盘
  15. 银行卡所属公司判断 参考自https://blog.csdn.net/well2049/article/details/79429130
  16. Linux - 磁盘操作
  17. MAX_STATEMENT_TIME uses confusing syntax
  18. vue 的 生命周期
  19. bzoj 3277 &amp; bzoj 3473,bzoj 2780 —— 广义后缀自动机
  20. Find command usage in Linux with excellent examples--reference

热门文章

  1. 2.vector数组
  2. 用Navicat连接MySQL数据库出现1251错误:密码方式错误
  3. linux网络防火墙-iptables基础详解
  4. 疯狂html5讲义(二):HTML5简的经常使用元素与属性(二):html5新增的通用属性
  5. Rdis-主从复制
  6. Java exception handling best practices--转载
  7. 二叉树的递归插入【Java实现】
  8. IDEA配置svn地址方法及出现的问题的解决办法
  9. 16、cgminer学习之:popen函数和system函数详解(执行系统命令)
  10. 【Codeforces Round #431 (Div. 2) C】From Y to Y