-
Notifications
You must be signed in to change notification settings - Fork 0
/
16439_치킨치킨치킨.cpp
58 lines (50 loc) · 991 Bytes
/
16439_치킨치킨치킨.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
vector<vector<int> > v;
bool visited[30] = {
false,
};
int final_result = 0;
int n, m;
void permutation(int start, int depth) {
if (depth == 3) {
int result = 0;
for (int i = 0; i < n; i++) {
int temp = 0;
for (int j = 0; j < m; j++) {
if (visited[j]) {
temp = max(temp, v[i][j]);
}
}
result += temp;
}
final_result = max(result, final_result);
return;
}
for (int i = start; i < m; i++) {
if (visited[i]) {
continue;
}
visited[i] = true;
permutation(i + 1, depth + 1);
visited[i] = false;
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n >> m;
v.resize(n, vector<int>(m));
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cin >> v[i][j];
}
}
permutation(0, 0);
cout << final_result;
return 0;
}