ecnu 丽娃河的狼人传说

http://acm.ecnu.edu.cn/problem/3263/

按照右边最小排序贪心即可

#include 
using namespace std;
#define mme(i,j) memset(i,j,sizeof(i))
bool vis[1005];
struct ode
{
    int left,right,need;
}node[10005];

bool cmp(ode a,ode b)
{
    if(a.right==b.right)
        return a.leftelse
        return a.rightint main()
{
    int t;
    scanf("%d",&t);
    int Case=0;
    while(t--)
    {
        mme(vis,0);
        int n,m,k,x;
        scanf("%d%d%d",&n,&m,&k);
        for(int i=0;iscanf("%d",&x);
            vis[x]=1;
        }
        int ans=0;
        for(int i=0;iscanf("%d%d%d",&node[i].left,&node[i].right,&node[i].need);
        sort(node,node+m,cmp);
        for(int i=0;iif(node[i].right-node[i].left+11;
                break;
            }
            int tmp=0;
            for(int k=node[i].left;k<=node[i].right;k++)
            {
                if(vis[k])
                    tmp++;
            }
            if(tmpfor(int h=node[i].right;h>=node[i].left && tmp>0;h--)
            {
                if(vis[h]==0)
                {
                    tmp--;
                    vis[h]=1;
                }
                if(tmp<=0)
                    break;
            }
        }
        printf("Case %d: %d\n", ++Case, ans);
    }
    return 0;
}
//3
//5 1 3
//1 3 5
//2 3 2

//5 2 3
//1 3 5
//2 3 2
//3 5 3

//5 2 3
//1 3 5
//2 3 2
//4 5 1

你可能感兴趣的:(各种套题)