NWU_ACM

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct point {
    int x,id;
    char na[201];
    bool operator <(const point & q) const
    {
        if (x==q.x) return q.id<id;
        return x<q.x;
    }
};
point pe[150001];
int nex[150001],a[150001];
int main()
{
    int t,n,m,z,i,x,y,w;
    while (~scanf("%d",&t))
    {
        while (t--)
        {
            scanf("%d %d %d",&n,&m,&z);
            memset(nex,0,sizeof(nex));
            for (i=1;i<=n;i++)
            {
                scanf("%s",pe[i].na);
                scanf("%d",&pe[i].x);
                pe[i].id=i;
            }
            while (m--)
            {
                scanf("%d %d",&x,&y);
                nex[x]+=y;
            }
            nex[n]=n;
            int ans=1;
            priority_queue<point> que;
            for (i=1;i<=n;i++)
            {
                que.push(pe[i]);
                while (nex[i]--)
                {
                    if (que.size()==0) break;
                    point temp=que.top(); que.pop();
                    a[ans++]=temp.id;
                }
            }
            while (z--)
            {
                scanf("%d",&w);
                if (z!=0) printf("%s ",pe[a[w]].na);
                else printf("%s\n",pe[a[w]].na);
            }
        }
    }
    return 0;
}

 

posted on 2017-03-27 13:09  NWU_ACM  阅读(121)  评论(0编辑  收藏  举报