比赛 |
20191022轻松模拟测试 |
评测结果 |
WWWWWWWWAW |
题目名称 |
Rotate Columns |
最终得分 |
10 |
用户昵称 |
ziiidan |
运行时间 |
0.016 s |
代码语言 |
C++ |
内存使用 |
13.70 MiB |
提交时间 |
2019-10-22 18:17:16 |
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn = 105;
const int INF = 0x7fffffff;
int T;
int n, m, maxval, ans;
int a[maxn][maxn];
int val[maxn];
int read(void)
{
int s = 0, w = 1;
char ch = getchar();
for(; ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') w = -1;
for(; ch <= '9' && ch >= '0'; ch = getchar()) s = s * 10 + ch - '0';
return s * w;
}
bool cmp(int rr, int tt)
{
return rr > tt;
}
int main()
{
freopen("happygameT1.in", "r", stdin);
freopen("happygameT1.out", "w", stdout);
T = read();
for(; T; T--)
{
n = read(); m = read();
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++) a[i][j] = read();
for(int i = 1; i <= m; i++)
{
maxval = -INF;
for(int j = 1; j <= n; j++) maxval = max(maxval, a[j][i]);
val[i] = maxval;
}
sort(val + 1, val + m + 1, cmp);
ans = 0;
for(int i = 1; i <= n; i++) ans += val[i];
cout << ans << '\n';
}
return 0;
}