Day 9 submission
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int height_map[100*100];
|
||||
|
||||
for(int i = 0; i < 100; i++)
|
||||
{
|
||||
string in;
|
||||
cin >> in;
|
||||
for(int j = 0; j < 100; j++)
|
||||
{
|
||||
height_map[j+i*100] = (int)in[j]-(int)'0';
|
||||
}
|
||||
}
|
||||
|
||||
int result = 0;
|
||||
for(int i = 0; i < 100*100; i++)
|
||||
{
|
||||
if (i-100 >= 0 && height_map[i-100] <= height_map[i])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (i+100 < 100*100 && height_map[i+100] <= height_map[i])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (i-1 >= 0 && height_map[i-1] <= height_map[i])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (i+1 < 100*100 && height_map[i+1] <= height_map[i])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
result += height_map[i]+1;
|
||||
}
|
||||
|
||||
cout << result << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user