比赛 |
20191022轻松模拟测试 |
评测结果 |
WWWWWWWWAA |
题目名称 |
Rotate Columns |
最终得分 |
20 |
用户昵称 |
CoolBoy小逴 |
运行时间 |
0.025 s |
代码语言 |
C++ |
内存使用 |
13.70 MiB |
提交时间 |
2019-10-22 17:32:20 |
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
const int maxn = 10010;
int T, n, m, x, cnt, ans, tot;
int a[maxn];
int f_;
char ch_;
template <class T>
inline T read(T &x_){
x_ = 0, f_ = 1, ch_ = getchar();
while (!isdigit(ch_)) {if (ch_ == '-') f_ = -1; ch_ = getchar();}
while (isdigit(ch_)){x_ = (x_ << 3) + (x_ << 1) + ch_ - 48; ch_ = getchar();}
return x_ *= f_;
}
int main(){
freopen ("happygameT1.in", "r", stdin);
freopen ("happygameT1.out", "w", stdout);
read(T);
for (; T; --T){
read(n);
read(m);
cnt = 0; tot = 0; ans = 0;
for (register int i = 1;i <= n; ++i)
for (register int j = 1;j <= m; ++j){
read(x);
a[++cnt] = x;
}
sort (a + 1, a + cnt + 1);
for (register int i = cnt;i >= 1; --i){
ans += a[i];
tot++;
if (tot == n) break;
}
printf ("%d\n", ans);
}
return 0;
}