1036. Boys vs Girls

来源:互联网 发布:怎么下载word软件 编辑:程序博客网 时间:2024/06/04 18:12
#include <cstdio>#include <queue>using namespace std ;typedef struct S{char name[20] ;char ID[20] ;int grade ;bool operator < (const S s)const{return grade > s.grade ;}}S ;int main(void){int N ;priority_queue<S>male ;priority_queue<S>female ;int fLow , mLow ;//freopen("input.txt" , "r" , stdin);scanf("%d" , &N);while(N--){S s ;char gendar ;scanf("%s %c %s %d" , s.name , &gendar , s.ID , &s.grade );if(gendar == 'M'){male.push(s);}else{female.push(s);}}if(female.empty()){fLow = -1 ;printf("Absent\n");}else{S s ;while( !female.empty()){s = female.top();female.pop();}fLow = s .grade ;printf("%s %s\n" , s.name , s.ID);}if(male.empty()){mLow = -1 ;printf("Absent\n");}else{mLow = male.top().grade;printf("%s %s\n" , male.top().name , male.top().ID);}if(fLow == -1 || mLow == -1){printf("NA\n");}else{printf("%d\n" , fLow - mLow);}return 0 ;}

0 0
原创粉丝点击