2015长春现场赛

1.Alisha’s Party(hdu 5437)

   优先队列模拟,共k个人,每个人有一个价值,m次进入,每次价值最大的进去,价值相同id小的先进去,a b前a个没进去的人进去b个,不够b个,都进去,m次操作后,剩下的都进去,最后输出查询的第i个进去的人的名字

  需要注意的是,m是乱序给的,需要按照a进行排序

  

#include<bits/stdc++.h>
using namespace std;
const int maxn=150005;
char name[maxn][205];
typedef pair<int,int> dl;
dl pt[maxn],px[maxn];
int ans[maxn],T[maxn],k,m,Q,u,v;

struct node{
    int id,val;
    node(int a=0,int b=0):id(a),val(b){}
    bool operator < (const node& x)const{
        if(x.val==val)
          return x.id<id;
        return x.val>val;
    }
};

void input(){
    scanf("%d%d%d",&k,&m,&Q);
    for(int i=1;i<=k;i++){
        scanf("%s%d",name[i],&u);
        pt[i]=make_pair(i,u);
    }
    for(int i=1;i<=m;i++){
        scanf("%d%d",&u,&v);
        px[i]=make_pair(u,v);
    }
    for(int i=0;i<Q;i++)
      scanf("%d",T+i);
    sort(px+1,px+1+m);
}
priority_queue<node> q;

void solve(){
    while(!q.empty())q.pop();
    int cnt1=0,cnt2=0;
    for(int i=1;i<=m;i++){
        while(cnt1<px[i].first){
            cnt1++;
            q.push(node(pt[cnt1].first,pt[cnt1].second));
        }
        int w=cnt2+px[i].second;
        while(cnt2<w&&!q.empty()){
            ++cnt2;
            node tmp=q.top();q.pop();
            ans[cnt2]=tmp.id;
        }
    }
    for(int i=cnt1+1;i<=k;i++)
      q.push(node(pt[i].first,pt[i].second));
    while(!q.empty()){
        ++cnt2;
        node tmp=q.top();q.pop();
        ans[cnt2]=tmp.id;
    }
    bool ok=0;
    for(int i=0;i<Q;i++){
        if(ok)putchar(‘ ‘);
        else ok=1;
        printf("%s",name[ans[T[i]]]);
    }
    puts("");
}

int main(){
    int t;
    scanf("%d",&t);
    while(t--){
        input();
        solve();
    }
    return 0;
}
时间: 2024-08-07 14:47:49

2015长春现场赛的相关文章

HDU 4791 Rebuild (2015长春现场赛,计算几何+三分)

Rebuild Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 521    Accepted Submission(s): 125 Problem Description Archaeologists find ruins of Ancient ACM Civilization, and they want to rebuild i

HDU 4815 2013长春现场赛C题

C - Little Tiger vs. Deep Monkey Time Limit:1000MS     Memory Limit:65535KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 4815 Description A crowd of little animals is visiting a mysterious laboratory ? The Deep Lab of SYSU. "Are y

2015长春网络赛总结

早上七点多就(冻)醒来了,训练了一个暑假,acm生涯的第一场网络赛,很激动. 九点开打,我拔不出网线,用的机房电脑,装的cb有问题,不能编译,只好用dev.男神电脑插上网线没有网,习惯了linux可能不习惯吧.这提醒我们以后一定要早点去把环境调好. 第三分钟,G题有人A了.我跟560开始看题,男神还在弄电脑.题意是给你n个数(n<1000),然后q(q<1000)次询问,要求你输出[l,r]区间的最大值.数据很小,我说暴力,然后560说线段树,然后模板13分钟1Y.然后560开始搞J,一个貌似

2015长春区域赛赛后总结

比赛时间:2015.10.18 队名:哆啦小黄埋(alone kampai UMR) 成员:ST,QL,WC 解出题目:两道 网络赛的时候并没有出线,老师争取到了女队名额,才有了参加区域赛的机会(谢谢老师么么哒~ 这次的比赛打铁没有什么可怨的,实力不足+比赛策略不当+心里素质差,每一条都是超级致命的(哭 过了的两道水题,L和F,L是经过ST和WC讨论之后1A的,F是我和ST讨论过敲得,ST去看其他题,而我就在一直卡题.由于代码奇葩,队友都看不懂,只能干着急+出数据,所以只能自己调试,WA好多发,

HDU5572 2015上海现场赛A题1001

1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<queue> 5 #include<map> 6 #include<set> 7 #include<cmath> 8 using namespace std; 9 typedef long long LL; 10 const double eps = 1e-8; 11 int sgn

hdu 5538 House Building(长春现场赛——水题)

题目链接:acm.hdu.edu.cn/showproblem.php?pid=5538 House Building Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 621    Accepted Submission(s): 398 Problem Description Have you ever played the vid

2015长春网络赛1001 求连通快数量的问题dfs

Ponds Time Limit: 1500/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1288    Accepted Submission(s): 429 Problem Description Betty owns a lot of ponds, some of them are connected with other ponds by pipes, a

Travel(HDU 5441 2015长春区域赛 带权并查集)

Travel Time Limit: 1500/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 2404    Accepted Submission(s): 842 Problem Description Jack likes to travel around the world, but he doesn’t like to wait. Now, he is tr

hdu 5441 (2015长春网络赛E题 带权并查集 )

n个结点,m条边,权值是 从u到v所花的时间 ,每次询问会给一个时间,权值比 询问值小的边就可以走 从u到v 和从v到u算不同的两次 输出有多少种不同的走法(大概是这个意思吧)先把边的权值 从小到大排序 询问值也按从小到大排序num记录集合里元素的个数每合并两个集合 ans增加 2*num[u]*num[v] Sample Input15 5 3 //n w q2 3 63341 5 157243 5 57054 3 123821 3 2172660001000013000 Sample Out