class Solution {
public:
vector<int> maxAltitude(vector<int>& heights, int limit) {
vector<int> res;
//为空的时候
if(heights.empty()) return heights;
//limit为1的时候
if(limit==1) return heights;
deque<int> d;
//特殊考虑,刚开始d为空的时候
if(d.empty()){
int max=0;
for(int i=0;i<limit;i++){
if(heights[i]>max) max=heights[i];
}
d.push_back(max);
res.push_back(max);
}
if(!d.empty()){
for(int i=0,j=limit;i<heights.size()-limit+1;i++,j++){//for里面一个一个移动
if(j>(heights.size()-1)) return res;