[SWEA]1206.View

Posted by kyoungIn on March 12, 2019

1206. [S/W 문제해결 기본] 1일차 - View

풀이

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
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
int main(){
    for(int idx=1;idx<=10;idx++){
        queue<int> q;
        int l,result=0; cin >> l;
        vector<int> v(l,0);
        for(int i=0;i<l;i++){
            int high;
            cin >> high;
            v[i]=high;
        }

        for(int i=2;i<l-2;i++){
            if(v[i]<=v[i-1] || v[i]<=v[i-2] || v[i]<=v[i+1] || v[i]<=v[i+2]) continue;
            int minFloor= v[i] - max(max(v[i-1],v[i-2]),max(v[i+1],v[i+2]));
            result+=minFloor;
            }
        
        cout <<'#' << idx << ' ' <<result << '\n';
    }
    
}