2014 Asia Shanghai Regional Contest H

Long long ago there is a strong tribe living on the earth. They always have wars and eonquer others.

One day, there is another tribe become their target. The strong tribe has decide to terminate them!


#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#define LL long long
#define WW freopen("in.txt","r",stdin)
#define RR freopen("out.txt","w",stdout)
#define INF 0x3f3f3f3f

using namespace std;
const int maxn = 100100;

class My
{
public:

    int At,Df;
    bool operator < (const struct My a)const
    {
        return At == a.At ? Df > a.Df : At > a.At;
    }
};

class Enemy
{
public:
    int At,Df;
    bool operator < (const struct Enemy a)const
    {
        return Df == a.Df ? At > a.At : Df > a.Df;
    }
};

My a[maxn];
Enemy b[maxn];

int main()
{
    int T;
    scanf("%d",&T);
    int cas = 0;
    while(T--)
    {
        int n,m;

        scanf("%d%d",&n,&m);

        for(int i=0;i S;
        int j = 0;
        int num = n;
        bool flag = true;
        for(int i=0;i= b[i].Df)
                S.insert(a[j++].Df);
            if(S.empty())
            {
                flag = false;
                break;
            }
            multiset::iterator it;
            it = S.lower_bound(b[i].At+1);
            if(it == S.end())
            {
                S.erase(S.begin());
                num--;
            }
            else
                S.erase(it);
        }
        if(!flag)
            printf("Case #%d: -1\n",++cas);
        else
            printf("Case #%d: %d\n",++cas,num);

    }

    return 0;
}


你可能感兴趣的:(2014 Asia Shanghai Regional Contest H)