比赛 |
20191022轻松模拟测试 |
评测结果 |
WWWWWWWWAA |
题目名称 |
Rotate Columns |
最终得分 |
20 |
用户昵称 |
BYVoid |
运行时间 |
0.023 s |
代码语言 |
C++ |
内存使用 |
14.32 MiB |
提交时间 |
2019-10-22 17:24:56 |
显示代码纯文本
#include<cstdio>
#include<algorithm>
#define re register
#define maxn 1000
using namespace std;
inline int read() {
int s=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9') {
if(ch=='-')f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9'){
s=(s<<3)+(s<<1)+ch-'0';
ch=getchar();
}
return s*f;
}
int t,n,m,tot,x,ans;
int a[maxn];
int main() {
freopen("happygameT1.in","r",stdin);
freopen("happygameT1.out","w",stdout);
t=read();
for(;t;--t) {
n=read();
m=read();
tot=0;ans=0;
for(re int i=1;i<=n;++i) {
for(re int j=1;j<=m;++j) {
x=read();
a[++tot]=x;
}
}
sort(a+1,a+1+tot);
for(re int i=1;i<=n;++i) {
//printf("%d ",a[i]);
ans+=a[tot-i+1];
}
printf("%d\n",ans);
}
return 0;
}
/*
2
2 3
2 5 7
4 2 4
3 6
4 1 5 2 10 4
8 6 6 4 9 10
5 4 9 5 8 7
10 3 6 46 546 9
5 3 45 46 8 6
7 5 6 67 7 5
10 5 3 685 1
10
8
10 10 9 9 8*/