refer
link
//總評分在 [G, 100] 區間內者,可以得到 50 元 PAT 代金券;
//在 [60, G) 區間內者,可以得到 20 元PAT代金券,
//同時任課老師還會把總評成績前 K 名的學生列入課程“名人堂”
//本題就請你撰寫程式,幫助老師列出名人堂的學生,
//并統計一共發出了面值多少元的 PAT 代金券,
//第一行給出 3 個整數:
//N(不超過 10 000 的正整數,為學生總數)、
//G(在 (60,100) 區間內的整數,為題面中描述的代金券等級分界線)、
//K(不超過 100 且不超過 N 的正整數,為進入名人堂的最低名次),
//接下來 N 行,
//每行給出一位學生的賬號(長度不超過15位、不帶空格的字串)
//和
//總評成績(區間 [0, 100] 內的整數),
/*
10 80 5
cy@zju.edu.cn 78
cy@pat-edu.com 87
1001@qq.com 65
uh-oh@163.com 96
test@126.com 39
anyone@qq.com 87
zoe@mit.edu 80
jack@ucla.edu 88
bob@cmu.edu 80
ken@163.com 70
*/
///----------------
/// 首先在一行中輸出發出的 PAT 代金券的總面值,
/// //然后按總評成績非升序輸出進入名人堂的學生的名次、賬號和成績,
//需要注意的是:成績相同的學生享有并列的排名,排名并列時,按賬號的字母序升序輸出,
/*
360
1 uh-oh@163.com 96
2 jack@ucla.edu 88
3 anyone@qq.com 87
3 cy@pat-edu.com 87
5 bob@cmu.edu 80
5 zoe@mit.edu 80
*/
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
const int M = 10010;
int N, G, K;
int sum = 0;
//map<string, int>m;//email-id
//int score[M] = {0};//id-score
vector<int>v1,v2;//存放id[60,G),[G,100]
struct Stu {
string email;
int score;
//int money;
int rank;
}stu[M];
bool cmp(Stu a, Stu b) {
if (a.score != b.score)return a.score > b.score;
else return a.email< b.email;
}
int main() {
cin >> N >> G >> K;
for (int i = 0; i < N; i++) {
//string email;
//getline(cin, stu[i].email);
cin >> stu[i].email;
//stu[i].email = email;
cin >> stu[i].score;
//m[email] = i;
//score[i] = grade;
if (stu[i].score < G && stu[i].score >= 60)
sum += 20;
if (stu[i].score >= G && stu[i].score <= 100)
sum += 50;
}
cout << sum << endl;
sort(stu, stu + N, cmp);
cout << 1 << " " << stu[0].email << " " << stu[0].score << endl;
stu[0].rank = 1;
for (int i = 1; i <=N; i++) {
if (stu[i].score == stu[i - 1].score)
stu[i].rank = stu[i - 1].rank;
else
stu[i].rank = i+1;
}
for (int i = 1; stu[i].rank <= K; i++) {
cout<<stu[i].rank << " " << stu[i].email << " " << stu[i].score << endl;
}
return 0;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/226854.html
標籤:其他
上一篇:零差檢測,外差檢測 以及 激光雷達中的零差探測和外差探測
下一篇:簡單的光線追蹤繪制場景
