-
Notifications
You must be signed in to change notification settings - Fork 17
/
main.cpp
45 lines (36 loc) · 930 Bytes
/
main.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
#include <vector>
#include <iostream>
using namespace std;
int largestHourglassesSum(const vector<vector<int>> &array)
{
int largestSum = -100;
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
int sum = 0;
sum += array[i + 0][j + 0];
sum += array[i + 0][j + 1];
sum += array[i + 0][j + 2];
sum += array[i + 1][j + 1];
sum += array[i + 2][j + 0];
sum += array[i + 2][j + 1];
sum += array[i + 2][j + 2];
largestSum = max(largestSum, sum);
}
}
return largestSum;
}
int main()
{
vector<vector<int>> array(6, vector<int>(6));
for(int i = 0; i < 6; i++)
{
for(int j = 0; j < 6; j++)
{
cin >> array[i][j];
}
}
cout << largestHourglassesSum(array) << endl;
return 0;
}