-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathw2_p3.cpp
More file actions
44 lines (36 loc) · 845 Bytes
/
Copy pathw2_p3.cpp
File metadata and controls
44 lines (36 loc) · 845 Bytes
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 <bits/stdc++.h>
using namespace std;
int main()
{
vector<vector<int>> mat;
int col, row;
cin >> col >> row;
mat.resize(col, vector<int>(row, 0));
for (int i = 0; i < col; i++)
{
int temp;
for (int j = 0; j < row; j++)
{
cin >> temp;
mat[i][j] = temp;
}
}
int max_sum = 0;
int row_temp = 0;
for (int i = 0; i < col; i++)
{
row_temp = accumulate(mat[i].begin(), mat[i].end(), 0);
for (int j = 0; j < row; j++)
{
int col_temp = 0;
for (int s = 0; s < col; s++)
{
col_temp += mat[s][j];
}
int sum = row_temp + col_temp - mat[i][j];
if (sum > max_sum)
max_sum = sum;
}
}
cout << max_sum;
}