zoukankan      html  css  js  c++  java
  • BZOJ 1034 [ZJOI2008]泡泡堂BNB

    贪心。和田忌赛马差不多。但是更简单一些。

    最强的能赢就赢,最弱的能赢就赢,其他情况用最弱的拼对方最强的,感性想是这样的。。

    View Code
     1 #include <iostream>
     2 #include <cstring>
     3 #include <cstdio>
     4 #include <cstdlib>
     5 #include <algorithm>
     6  
     7 #define N 200000
     8  
     9 using namespace std;
    10  
    11 int n;
    12 long long a[N],b[N];
    13  
    14 inline void read()
    15 {
    16     scanf("%d",&n);
    17     for(int i=1;i<=n;i++)
    18         scanf("%lld",&a[i]);
    19     for(int i=1;i<=n;i++)
    20         scanf("%lld",&b[i]);
    21     sort(a+1,a+1+n);
    22     sort(b+1,b+1+n);
    23 }
    24 
    25 inline long long getans(long long *a,long long *b)
    26 {
    27     long long ans=0;
    28     int h=1,t=n;
    29     int h1=1,t1=n;
    30     while(h<=t)
    31     {
    32         if(a[h]>b[h1]) ans+=2,h++,h1++;
    33         else if(a[t]>b[t1]) ans+=2,t--,t1--;
    34         else
    35         {
    36             if(a[h]==b[t1]) ans+=1;
    37             h++,t1--;
    38         }
    39     }
    40     return ans;
    41 }
    42 
    43 inline void go()
    44 {
    45     printf("%lld %lld\n",getans(a,b),2*n-getans(b,a));
    46 }
    47  
    48 int main()
    49 {
    50     read();
    51     go();
    52     return 0;
    53 }
  • 相关阅读:
    java 截取pdf
    webService 发送soap请求,并解析返回的soap报文
    常用网址
    扫描文件夹下代码行数
    CodeMIrror 简单使用
    常用 linux 命令(部分)
    windows下RabbitMQ 监控
    一定要写的日志
    创业思路
    10月9日后计划
  • 原文地址:https://www.cnblogs.com/proverbs/p/2867078.html
Copyright © 2011-2022 走看看