-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path14647.cpp
More file actions
60 lines (55 loc) ยท 860 Bytes
/
14647.cpp
File metadata and controls
60 lines (55 loc) ยท 860 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// 14647. ์ค์ค๋ ์กฐ๋ฅํ์ค์ผ!!
// 2019.08.17
// ๊ตฌํ
#include<iostream>
#include<algorithm>
using namespace std;
int n, m;
int map[502][502];
int main()
{
cin >> n >> m;
int ans = 0;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
int k;
cin >> k;
int cnt = 0;
while (k > 0)
{
if (k % 10 == 9)
{
cnt++;
}
k /= 10;
}
map[i][j] = cnt;
ans += cnt;
}
}
int sumMax = 0; // ํ ๋๋ ์ด์ 9๊ฐ ๊ฐ์ฅ ๋ง์ด ๋ค์ด์๋ ๊ฐ์
// ํ ๊ณ์ฐ
for (int i = 0; i < n; i++)
{
int sum = 0;
for (int j = 0; j < m; j++)
{
sum += map[i][j];
}
sumMax = max(sumMax, sum);
}
// ์ด ๊ณ์ฐ
for (int i = 0; i < m; i++)
{
int sum = 0;
for (int j = 0; j < n; j++)
{
sum += map[j][i];
}
sumMax = max(sumMax, sum);
}
cout << ans - sumMax << endl;
return 0;
}