-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1206.cpp
More file actions
43 lines (41 loc) · 702 Bytes
/
1206.cpp
File metadata and controls
43 lines (41 loc) · 702 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
// 1206. View
// 2019.07.05
#include<iostream>
#include<vector>
using namespace std;
int main()
{
for (int test_case = 1; test_case <= 10; test_case++)
{
int n;
cin >> n;
vector<int> v(n);
for (int i = 0; i < n; i++)
{
cin >> v[i];
}
int cnt = 0;
for (int i = 2; i < n - 2; i++)
{
int min = 255;
// 앞뒤 2칸 조사해서 조망권이 있는지 확인
for (int j = -2; j < 3; j++)
{
if (v[i] <= v[i + j] && j != 0)
{
break;
}
else if (v[i] > v[i + j])
{
min = min < v[i] - v[i + j] ? min : v[i] - v[i + j];
}
if (j == 2)
{
cnt += min;
}
}
}
cout << "#" << test_case << " " << cnt << endl;
}
return 0;
}