-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTong_tang_max.cpp
44 lines (38 loc) · 941 Bytes
/
Tong_tang_max.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <iostream>
#include <vector>
#include <algorithm>
int main() {
int n, m;
std::cin >> n >> m;
std::vector<std::vector<int>> a(n);
for (int i = 0; i < n; ++i) {
a[i] = std::vector<int>(m);
for (int j = 0; j < m; ++j) {
std::cin >> a[i][j];
}
std::sort(a[i].rbegin(), a[i].rend());
}
try {
for (int i = n - 2; i >= 0; --i) {
int point = 0;
while (a[i][0] >= a[i + 1][0]) {
a[i].erase(a[i].begin());
if (a[i].empty()) {
break;
}
}
}
int ans = 0;
for (int i = 0; i < n; ++i) {
if (a[i].empty()) {
ans = 0;
break;
}
ans += a[i][0];
}
std::cout << ans << std::endl;
} catch (...) {
std::cout << 0 << std::endl;
}
return 0;
}