我希望你是我独家记忆

一段永远封存的记忆,随风而去
posts - 263, comments - 31, trackbacks - 0, articles - 3
   :: 首页 :: 新随笔 ::  :: 聚合  :: 管理

HLOJ_1017

Posted on 2009-10-12 14:47 Hero 阅读(204) 评论(0)  编辑 收藏 引用 所属分类: 代码如诗--ACM
 1 //HLOJ_1017 string 可以用compare()来排序
 2 
 3 #include <iostream>
 4 #include <string>
 5 using namespace std ;
 6 
 7 const int size = 1100 ;
 8 
 9 int data[size] ;
10 
11 struct NODE
12 {
13     string name ;
14     int score ;
15 };
16 struct NODE student[size] ;
17 
18 int inn, inm, ing ;
19 
20 int cmp( const void *a, const void * b )
21 {
22     struct NODE *= (struct NODE *)a ;
23     struct NODE *= (struct NODE *)b ;
24 
25     if( c->score != d->score )
26         return d->score - c->score ;
27     else
28         return c->name.compare( d->name ) ;
29 }
30 int main()
31 {
32     while( cin >> inn && inn )
33     {
34         cin >> inm >> ing ;
35         forint i=1; i<=inm; i++ )
36         {
37             cin >> data[i] ;
38         }
39 
40         int nump = 0 ;
41         int ID = 0 ;
42         forint i=1 ;i<=inn; i++ )
43         {
44             cin >> student[i].name ;
45             student[i].score = 0 ;
46 
47             cin >> nump ;
48             forint j=1; j<=nump; j++ )
49             {
50                 cin >> ID ;
51                 student[i].score += data[ID] ;
52             }
53         }
54 
55         qsort( student+1, inn, sizeof(student[0]), cmp ) ;
56 
57         int out = 0 ;
58         forint i=1; i<=inn; i++ )
59         {
60             if( student[i].score >= ing ) out++ ;
61         }
62         printf( "%d\n"out ) ;
63 
64         forint i=1; i<=inn; i++ )
65         {
66             if( student[i].score < ing ) break ;
67 
68             cout << student[i].name << " " << student[i].score << endl ;
69         }
70     }
71     return 0 ;
72 }

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理