• 华东交通大学2015年ACM“双基”程序设计竞赛1003


    Problem C

    Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
    Total Submission(s) : 225   Accepted Submission(s) : 20

    Font: Times New Roman | Verdana | Georgia

    Font Size: ← →

    Problem Description

    《炉石传说:魔兽英雄传》(Hearthstone: Heroes of Warcraft,简称炉石传说)是暴雪娱乐开发的一款集换式卡牌游戏......
    简化下题目:两个玩家A和B在场上各有若干个牌(每个牌只有攻击力和血量两个属性,没有附加属性),每个回合中一张牌只能攻击一次,
    而且一张牌只能被攻击一次,攻击一张牌的同时也会受到被攻击牌的攻击,所扣的血量为攻击你牌的攻击力,当血量小于1时,这张卡会被消灭。
    当前回合中A先攻击,问A攻击后,B场上所留下牌的攻击力和的最小值为多少?

    Input

    第一行输入T(T<=10),代表有T组数据。
    每组数据中,第一行为n,m(0<n,m<8) 分别代表A场上有n张牌,B场上有m张牌。
    接下来的n行中,第i行输入Aa[i],Ab[i],Aa[i] Ab[i]分别表示A场上第i张牌的攻击力和血量。
    接下来的m行中,第i行输入Ba[i],Bb[i],Ba[i] Bb[i]分别表示B场上第i张牌的攻击力和血量。
    (0<Aa[i],Ab[i],Ba[i],Bb[i]<=10)

    Output

    每组数据输出一行,对应的是B场上所留下的攻击力和的最小值为多少.

    Sample Input

    1
    1 3
    2 1
    8 2
    7 2
    6 2

    Sample Output

    13

    Author

    moonlike
     
    和真正游戏还是不一样的,A每个只能攻击一次和B每个只能被攻击一次。
    那么,攻击者按照攻击力的低排到高排序,被攻击的攻击力高到低,攻击相等则血量低到高排序。然后就循环一下
    #include<stdio.h>
    //#include<bits/stdc++.h>
    #include<string.h>
    #include<iostream>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<queue>
    #include<map>
    #include<vector>
    #include<algorithm>
    #include<limits.h>
    #define inf 0x3fffffff
    #define INF 0x3f3f3f3f
    #define lson l,m,rt<<1
    #define rson m+1,r,rt<<1|1
    #define LL long long
    #define ULL unsigned long long
    using namespace std;
    struct P
    {
        int x,y;
    } hehe[1000];
    struct C
    {
        int x,y;
    } he[1000];
    bool cmd1(P a,P b)
    {
        return a.x<b.x;
    }
    bool cmd2(C a,C b)
    {
        if(a.x==b.x)
        {
            return a.y<b.y;
        }
        else
        {
            return a.x>b.x;
        }
    }
    int main()
    {
        int n,m;
        int t;
        int i,j;
        while(cin>>t)
        {
            while(t--)
            {
                int ans=0;
                cin>>n>>m;
                for(i=0; i<n; i++)
                {
                    cin>>hehe[i].x>>hehe[i].y;
                }
                for(i=0; i<m; i++)
                {
                    cin>>he[i].x>>he[i].y;
                }
                sort(hehe,hehe+n,cmd1);
                sort(he,he+m,cmd2);
                for(i=0; i<n; i++)
                {
                    for(j=0; j<m; j++)
                    {
                        if(hehe[i].x>=he[j].y&&he[j].x!=0)
                        {
                            he[j].x=0;
                            break;
                        }
                    }
                }
                for(i=0; i<m; i++)
                {
                    ans+=he[i].x;
                }
                cout<<ans<<endl;
            }
        }
        return 0;
    }
    

      

  • 相关阅读:
    hdu 4027 Can you answer these queries? 线段树
    ZOJ1610 Count the Colors 线段树
    poj 2528 Mayor's posters 离散化 线段树
    hdu 1599 find the mincost route floyd求最小环
    POJ 2686 Traveling by Stagecoach 状压DP
    POJ 1990 MooFest 树状数组
    POJ 2955 Brackets 区间DP
    lightoj 1422 Halloween Costumes 区间DP
    模板 有源汇上下界最小流 loj117
    模板 有源汇上下界最大流 loj116
  • 原文地址:https://www.cnblogs.com/yinghualuowu/p/5003122.html
Copyright © 2020-2023  润新知