zoukankan      html  css  js  c++  java
  • UVALive

    题目链接

    题意

    两人赛马,每居获胜得200,平局无事发生,输了也输200。求最优的策略使赢的钱最多。

    分析

    排序,从最快的开始比,若比不过,则用最弱的消耗最强的。模拟即可。

    #include<iostream>
    #include<cstdio>
    #include<cmath>
    #include<cstdlib>
    #include<algorithm>
    #include<cstring>
    #include <queue>
    #include <vector>
    #include<bitset>
    #include<map>
    #include<deque>
    #include<stack>
    using namespace std;
    typedef pair<int,int> pii;
    #define X first
    #define Y second
    #define pb push_back
    #define mp make_pair
    #define ms(a,b) memset(a,b,sizeof(a))
    const int inf = 0x3f3f3f3f;
    const int maxn = 1e6+5;
    const int mod = 77200211+233;
    #define lson l,m,2*rt
    #define rson m+1,r,2*rt+1
    typedef long long ll;
    int a[1024],b[1024];
    int main(){
    #ifdef LOCAL
        freopen("in.txt","r",stdin);
    #endif // LOCAL
        int n;
        while(scanf("%d",&n)&&n){
            for(int i=1;i<=n;i++) scanf("%d",&a[i]);
            for(int i=1;i<=n;i++) scanf("%d",&b[i]);
            int sta=1,stb=1,eda=n,edb=n;
            sort(a+1,a+1+n);
            sort(b+1,b+1+n);
            int ans=0;
            for(int i=1;i<=n;i++){
                if(a[eda]>b[edb]){
                    ans+=200;
                    eda--;
                    edb--;
                }else if(a[eda]<b[edb]){
                    ans-=200;
                    sta++;
                    edb--;
                }else{
                    if(a[sta]>b[stb]){
                        ans+=200;
                        sta++;
                        stb++;
                    }else if(a[sta]<b[edb]){
                        ans-=200;
                        sta++;
                        edb--;
                    }else{
                        sta++;
                        edb--;
                    }
                }
            }
            printf("%d
    ",ans);
        }
        return 0;
    }
  • 相关阅读:
    教你当主管:如何降低你的员工流失率?
    你问我这算什么
    推荐:职场提升的10条捷径
    压力从何而来呢?千万不要2008年结婚
    怎样“管理”你的上司?
    HTTP.sys
    IIS书籍
    IIS目录
    HTTP服务
    在 IIS 7 中使用配置文件
  • 原文地址:https://www.cnblogs.com/fht-litost/p/8919528.html
Copyright © 2011-2022 走看看