-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmat_max.cpp
61 lines (47 loc) · 835 Bytes
/
mat_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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <iostream>
#include <vector>
using namespace std;
int main()
{
long long int n;
long long int q;
cin >> n;
cin >> q;
long long int row[n];
long long int col[n];
for ( int i = 0; i < n; i++ ) {
row[i] = 0;
col[i] = 0;
}
for ( int i = 0; i < q; i++ ) {
string s;
cin >> s;
if ( s == "RowAdd" ) {
long long int r;
long long int mod;
cin >> r;
cin >> mod;
row[r] += mod;
} else if ( s == "ColAdd" ) {
long long int c;
long long int mod;
cin >> c;
cin >> mod;
col[c] += mod;
}
}
long long int maxr = 0;
for ( long long int i = 0; i < n; i++ ) {
if ( row[i] > maxr ) {
maxr = row[i];
}
}
long long int maxc = 0;
for ( long long int i = 0; i < n; i++ ) {
if ( col[i] > maxc ) {
maxc = col[i];
}
}
cout << maxr + maxc << endl;
return 0;
}