PAT (Advanced Level) 1083. List Grades (25)

简单排序。

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

struct X
{
    string s;
    string c;
    int g;
}p[100000];
int n;

bool cmp(const X&a,const X&b)
{
    return a.g>b.g;
}

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        cin>>p[i].s>>p[i].c>>p[i].g;
    sort(p+1,p+1+n,cmp);

    int flag=0;
    int L,U; scanf("%d%d",&L,&U);
    for(int i=1;i<=n;i++)
    {
        if(p[i].g>=L&&p[i].g<=U)
        {
            cout<<p[i].s<<" "<<p[i].c<<endl;
            flag=1;
        }
    }
    if(flag==0) printf("NONE\n");
    return 0;
}
时间: 2024-10-24 18:41:13

PAT (Advanced Level) 1083. List Grades (25)的相关文章

PAT (Advanced Level) 1021. Deepest Root (25)

先并查集判断连通性,然后暴力每个点作为根节点判即可. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> #include<cstdio> #include<queue> #include<vector> using namespace std; struct Edge { int a,b; }e[20000]; int n,sz

PAT (Advanced Level) 1020. Tree Traversals (25)

递归建树,然后BFS一下 #include<iostream> #include<cstring> #include<cmath> #include<algorithm> #include<cstdio> #include<queue> #include<vector> using namespace std; const int maxn=40; int a[maxn],b[maxn]; int n,tot; struc

PAT (Advanced Level) 1114. Family Property (25)

简单DFS. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #include<map> #include<queue> #include<stack> #include<algorithm> using namespace std; struct X { int id; int Father,Mother; int k;

PAT (Advanced Level) 1085. Perfect Sequence (25)

可以用双指针(尺取法),也可以枚举起点,二分终点. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #include<map> #include<queue> #include<stack> #include<algorithm> using namespace std; int n; long long k; long l

PAT (Advanced Level) 1071. Speech Patterns (25)

简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #include<map> #include<stack> #include<queue> #include<string> #include<iostream> #include<algorithm> using namespace std;

PAT (Advanced Level) 1109. Group Photo (25)

简单模拟. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #include<map> #include<queue> #include<stack> #include<string> #include<algorithm> #include<iostream> using namespace std

PAT (Advanced Level) 1101. Quick Sort (25)

树状数组+离散化 #include<cstdio> #include<cstring> #include<cmath> #include<map> #include<algorithm> using namespace std; const int maxn=100000+10; int a[maxn],ans[maxn],c[maxn],b[maxn]; int n; map<int,int>m; int lowbit(int x)

PAT (Advanced Level) 1063. Set Similarity (25)

读入之后先排序. 询问的时候可以o(m)效率得到答案. #include<cstdio> #include<cstring> #include<cmath> #include<queue> #include<vector> #include<string> #include<stack> #include<map> #include<algorithm> using namespace std; s

PAT (Advanced Level) 1105. Spiral Matrix (25)

简单模拟. #include<cstdio> #include<cstring> #include<cmath> #include<map> #include<queue> #include<string> #include<algorithm> using namespace std; const int maxn=10000+10; int N,a[maxn]; int ans[maxn]; int m,n; int