-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path14719.cpp
More file actions
66 lines (40 loc) · 894 Bytes
/
14719.cpp
File metadata and controls
66 lines (40 loc) · 894 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
61
62
63
64
65
66
//
// 14719.cpp
// algo
//
// Created by 박효정 on 2021/08/18.
//
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
cin.tie(0);
cout.tie(0);
std::ios::sync_with_stdio(false);
int w,h;
cin>>h>>w;
int res=0;
//세로 가로
vector<int>v(w+1);
for(int i=1;i<=w;i++){
cin>>v[i];
}
for(int i=2;i<w;i++){
int left=0;
int right=0;
for(int j=1;j<i;j++){
left=max(left, v[j]);
}
for(int j=i+1;j<=w;j++){
right=max(right,v[j]);
}
int cmp=0;
cmp=min(right,left);
if(cmp-v[i]>=0){
res+=cmp-v[i];
}
}
cout<<res<<"\n";
return 0;
}