问题 I: 排名
2024-10-08 09:33:12
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
struct stu {
char id[10];
int sum;
};
int main() {
int n, m, g;
while (scanf("%d%d%d", &n, &m, &g), n) {
int tab[m];
for (int i = 0; i < m; ++i) {
scanf(" %d", &tab[i]);
}
stu stus[n];
memset(stus, 0, sizeof(stus));
for (int j = 0; j < n; ++j) {
scanf(" %s", stus[j].id);
int t;
scanf(" %d", &t);
for (int i = 0; i < t; ++i) {
int n1;
scanf(" %d", &n1);
stus[j].sum += tab[n1-1];
}
}
sort(stus, stus + n, [](const stu &s1, const stu &s2) {
int temp;
temp = s1.sum - s2.sum;
if (temp == 0) {
int t2;
t2 = strcmp(s1.id, s2.id);
return t2 < 0;
} else return temp > 0;
});
int x = 0;
for (int k = 0; k < n; ++k) {
if (stus[k].sum >= g) x++;
}
printf("%d\n", x);
for (int l = 0; l < n; ++l) {
if (stus[l].sum >= g) printf("%s %d\n", stus[l].id, stus[l].sum);
}
}
return 0;
}
最新文章
- Discuz对不起,您安装的不是正版应用的解决办法
- django 1.8 TEMPLE_DIR和STATICFILES_DIRS配置
- 使用 HTML5 Canvas 绘制出惊艳的水滴效果
- win7 64位DCOM配置(关于导出excel 配置计算机组件服务)(转)
- 【Android】记录反编译安卓程序步骤
- Unity-Tween
- 在rails下新建表
- Android 进入页面默认定位到ListView的解决方法
- poj 2063 Investment
- windows同时安装两个jdk
- 【Objective-C】4-空指针和野指针
- How to convert an IPv4 address into a integer in C#?
- Java实现希尔排序
- sendto() 向广播地址发包返回errno 13, Permission denied错误
- Spring in action (1)
- Git托管
- element-ui,router.push到其他路由,菜单栏不会高亮对应的路由
- javascript正则表达式的一些笔记
- cf1073G Yet Another LCP Problem (SA+权值线段树)
- 【BZOJ2229】【ZJOI2011】最小割