PAT (Advanced Level) 1036. Boys vs Girls (25)

Posted Fighting Heart

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PAT (Advanced Level) 1036. Boys vs Girls (25)相关的知识,希望对你有一定的参考价值。

简单题。

#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<map>
#include<queue>
#include<vector>
using namespace std;

const int maxn=100000;
struct X
{
    string name;
    string sex;
    string id;
    int c;
}s[maxn];
int n;

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        cin>>s[i].name>>s[i].sex>>s[i].id>>s[i].c;
    int id1=-1,id2=-1;
    int Max=-1,Min=99999;
    for(int i=1;i<=n;i++)
        if(s[i].sex[0]==F&&s[i].c>Max) Max=s[i].c,id1=i;

    for(int i=1;i<=n;i++)
        if(s[i].sex[0]==M&&s[i].c<Min) Min=s[i].c,id2=i;

    if(id1==-1) printf("Absent\n");
    else cout<<s[id1].name<<" "<<s[id1].id<<endl;

    if(id2==-1) printf("Absent\n");
    else cout<<s[id2].name<<" "<<s[id2].id<<endl;

    if(id1==-1||id2==-1) printf("NA\n");
    else printf("%d\n",abs(s[id1].c-s[id2].c));

    return 0;
}

 

以上是关于PAT (Advanced Level) 1036. Boys vs Girls (25)的主要内容,如果未能解决你的问题,请参考以下文章

PAT Basic Level 1036

PAT (Advanced Level) 1025. PAT Ranking (25)

PAT Advanced Level 1044

PAT Advanced Level 1043

PAT Advanced Level 1079

PAT Advanced Level 1095