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';
}
}
|