#include<bits/stdc++.h>#include<vector>#include<iostream>#include<cstring>#include<algorithm>#include<queue>#include<map>#include<set>#include<stack>#define ll long long#define chushi(a, b) memset(a, b, sizeof(a))constdouble eps =1e-8;const ll INF =2e9;const ll mod =998244353;constint maxn =1e5+5;usingnamespace std;typedefstruct Node{
string s;// 名字 int sum;// 分数 }node;int fen[11];intsum(int n){// 计算总分, n 为该选手的过题数 int tot =0, num;for(int i =1; i <= n; i++){
cin >> num;
tot += fen[num];}return tot;}intcmp(node a, node b){// 自定义排序 if(a.sum == b.sum)return a.s < b.s;return a.sum > b.sum;}intmain(int argc,char*argv[]){
ios::sync_with_stdio(false);int n, m, g;while(cin >> n, n !=0){
cin >> m >> g;
node v[1005];for(int i =1; i <= m; i++) cin >> fen[i];// 纪录每个的分数 for(int i =1; i <= n; i++){
cin >> v[i].s;// 输入名字 int num; cin >> num;// 输入过题数
v[i].sum =sum(num);// 计算总分 }sort(v+1, v+1+n, cmp);// 排序 int ind =1;while(v[ind].sum >= g && ind <= n) ind++;// 统计过线的人
cout << ind -1<< endl;for(int i =1; i <= ind -1; i++) cout << v[i].s <<" "<< v[i].sum << endl;}return0;}
H题: HDU - 2093
#include<bits/stdc++.h>#include<vector>#include<iostream>#include<cstring>#include<algorithm>#include<queue>#include<map>#include<set>#include<stack>#define ll long long#define chushi(a, b) memset(a, b, sizeof(a))constdouble eps =1e-8;const ll INF =2e9;const ll mod =998244353;constint maxn =1e5+5;usingnamespace std;struct node{char name[20];// 人名 int cnt;// 题数 int score;// 分数 }stu[maxn];boolcmp(node x,node y){if(x.cnt != y.cnt)return x.cnt > y.cnt;elseif(x.score != y.score)return x.score < y.score;elsereturnstrcmp(x.name, y.name)<0;}intmain(){int n,m;while(~scanf("%d%d",&n,&m)){int t =0;// 统计人数 char ch[10];while(scanf("%s", stu[t].name)!=EOF){
stu[t].cnt =0, stu[t].score=0;for(int i =0; i < n; i++){scanf("%s", ch);if(ch[0]=='-')continue;if(strcmp(ch,"0")==0)continue;
stu[t].cnt++;// 更新题数int j, tmp =0;for(j =0; j <strlen(ch); j++){// 计算答题时间 if(ch[j]=='(')break;
tmp = tmp *10+ ch[j]-'0';}
stu[t].score += tmp;// 更新结果
tmp =0;if(j <strlen(ch)){//判断是否出错 for(int k = j +1; k <strlen(ch)-1; k++){
tmp = tmp *10+ ch[k]-'0';}}
stu[t].score += tmp * m;// 再次更新结果 }
t++;// 更新人数 }sort(stu, stu+t, cmp);for(int i =0; i < t; i++){printf("%-10s%3d%5d\n",stu[i].name, stu[i].cnt, stu[i].score);}}return0;}
I题: HDU - 1040
#include<bits/stdc++.h>#include<vector>#include<iostream>#include<cstring>#include<algorithm>#include<queue>#include<map>#include<set>#include<stack>#define ll long long#define chushi(a, b) memset(a, b, sizeof(a))constdouble eps =1e-8;const ll INF =2e9;const ll mod =998244353;constint maxn =1e5+5;usingnamespace std;intmain(int argc,char*argv[]){
ios::sync_with_stdio(false);int ncase;
cin >> ncase;while(ncase--){int n;
cin >> n;longlong a[n];for(int i =0; i < n; i++) cin >> a[i];sort(a, a +n);
cout << a[0];for(int i =1; i < n; i++) cout <<" "<< a[i];
cout << endl;}return0;}
J题: HDU - 1106
#include<bits/stdc++.h>#include<vector>#include<iostream>#include<cstring>#include<algorithm>#include<queue>#include<map>#include<set>#include<stack>#define ll long long#define chushi(a, b) memset(a, b, sizeof(a))constdouble eps =1e-8;const ll INF =2e9;const ll mod =998244353;constint maxn =1e5+5;usingnamespace std;intmain(int argc,char*argv[]){
ios::sync_with_stdio(false);
string s;while(cin >> s){replace(s.begin(),s.end(),'5',' ');// 把所有的 5 变成 空格,不变也可以,后边以 5 为结尾标志就可以
vector<int>v;// 纪录转化出来的数字
s =" "+ s;// 空格 + 数字 + 空格 + .... int ind =0;while(ind < s.size()){if(s[ind]==' ') ind++;// 空格就跳过 else{
string num ="";while(s[ind]!=' '&& ind < s.size()){// 分离字符串
num += s[ind];
ind++;}int a =atoi(num.c_str());// 字符串转数字
v.push_back(a);}}sort(v.begin(), v.end());// 排序
cout << v[0];for(int i =1; i < v.size(); i++) cout <<" "<< v[i];
cout << endl;}return0;}