11 solutions
-
0
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define LL long long #define ph push_back #define INF 0x3f3f3f3f #define PII pair<int, int> const int N =310; int n; struct stu{ string name; int grade; string level; bool operator <(const stu & W) const{ return grade>W.grade; } } stu[N]; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr), cout.tie(nullptr); cin>>n; for(int i=1;i<=n;i++){ cin>>stu[i].name>>stu[i].grade; } for(int i=1;i<=n;i++){ if(stu[i].grade==0) stu[i].level="Bad"; if(stu[i].grade>0&&stu[i].grade<200) stu[i].level="Not good"; if(stu[i].grade>=200&&stu[i].grade<300) stu[i].level="Bronze medal"; if(stu[i].grade>=300&&stu[i].grade<400) stu[i].level="Silver medal"; if(stu[i].grade>=400)stu[i].level="Gold medal"; } sort(stu+1,stu+1+n); for(int i=1;i<=n;i++){ cout<<stu[i].name<<' '<<stu[i].grade<<' '<<stu[i].level<<endl; } return 0; }
Information
- ID
- 110
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 5
- Tags
- # Submissions
- 215
- Accepted
- 79
- Uploaded By