`
ssun125
  • 浏览: 41069 次
文章分类
社区版块
存档分类
最新评论

HDU 1236 ( 排名 )

 
阅读更多
Problem : 1236 ( 排名 )     Judge Status : Accepted
RunId : 5684884    Language : C++    Author : ssun
Code Render Status : Rendered By HDOJ C++ Code Render Version 0.01 Beta

#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

struct ST {
    string id;
    int all;
    int prob[12];
    ST(){
        memset(prob,0,sizeof(prob));
        all = 0;
    }
};

int cmp(ST &st1,ST &st2)
{
    if(st1.all!=st2.all) return st1.all>st2.all;
    return st1.id<st2.id;
}

int main()
{
    int n,m,g;
    int i,j;
    int score[12];
    while(scanf("%d",&n),n)
    {
        ST st[1010];
        scanf("%d%d",&m,&g);
        int count = 0;
        memset(score,0,sizeof(score));
        for(i=0; i<m; i++) scanf("%d",&score[i]);    
        for(i=0; i<n; i++)
        {
            int all;
            cin>>st[i].id>>all;
            for(j=0; j<all; j++)
            {
                scanf("%d",&st[i].prob[j]);
                st[i].all += score[st[i].prob[j]-1]; 
            }
            if(st[i].all>=g) count++;
        }
        cout<<count<<endl;
        sort(st,st+n,cmp);
        for(i=0; i<n; i++)
        {
            if(st[i].all>=g) 
                cout<<st[i].id<<" "<<st[i].all<<endl;
        }
    }
    return 0;
}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics