liusizhe88 @ 2024-08-14 11:17:29
#include<bits/stdc++.h>
using namespace std;
struct Node{
int val;
int next;
};
int main(){
int n,m,c=0,d,e,f=0;
cin>>n>>m;
Node node[n];
int a[n-m+1],b[n-m+1];
for(int i=0;i<n;i++){
cin>>node[i].val;
if(i>=1){
node[i-1].next=node[i].val;
}
}
e=d=node[0].val;
for(int i=0;i<n;i++){
if(node[i].val!=NULL){
c++;
if(node[i].val<d){
d=node[i].val;
}
if(node[i].val>e){
e=node[i].val;
}
}
if(c==m){
a[f]=d;
b[f]=e;
node[f].val=NULL;
i=f;
c=0;
e=node[f+1].val;
d=node[f+1].val;
f++;
}
}
for(int i=0;i<n-m+1;i++){
cout<<a[i]<<" ";
}
cout<<endl;
for(int i=0;i<n-m+1;i++){
cout<<b[i]<<" ";
}
return 0;
}