-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path18228.cpp
More file actions
44 lines (39 loc) · 753 Bytes
/
18228.cpp
File metadata and controls
44 lines (39 loc) · 753 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
// 18228. 펭귄추락대책위원회
// 2019.12.24
// 입문용
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
const int MAX_VALUE = 2147483647;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
vector<int> v(n);
int idx = 0;
for (int i = 0; i < n; i++)
{
cin >> v[i];
if (v[i] == -1)
{
idx = i;
}
}
// 왼쪽
int leftMin = MAX_VALUE;
for (int i = 0; i < idx; i++)
{
leftMin = min(leftMin, v[i]);
}
int rightMin = MAX_VALUE;
for (int i = idx + 1; i < n; i++)
{
rightMin = min(rightMin, v[i]);
}
cout << leftMin + rightMin << endl;
return 0;
}