Xfer_splendor @ 2021-07-15 16:35:13
样例过不了
#include<iostream>
#include<queue>
using namespace std;
int n,k,a[100001];
deque<int>s;
int main(){
cin>>n>>k;
for (int i=1;i<=n;++i){
cin>>a[i];
}
for (int i=1;i<=n;++i){
while (!s.empty()&&s.front()<=a[i]){
s.pop_front();
}
s.push_front(a[i]);
while (s.size()>k){
s.pop_back();
}
if (i>=k){
cout<<s.back()<<" ";
}
}
cout<<endl;
for (int i=1;i<=n;++i){
while (!s.empty()&&s.front()>=a[i]){
s.pop_front();
}
s.push_front(a[i]);
while (s.size()>k){
s.pop_back();
}
if (i>=k){
cout<<s.back()<<" ";
}
}
return 0;
}
by Froranzen @ 2021-07-16 15:11:09
可能表达不清楚,毕竟我很少回答问题(
by Froranzen @ 2021-07-16 15:11:57
啊这,没事,能者多劳。