number2003 @ 2023-12-14 12:25:28
#define _CRT_SECURE_NO_WARNINGS 1
#include<vector>
#include<algorithm>
#include<iostream>//cin头文件
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int a = 0;
int b = 0;
int main()
{
ios::sync_with_stdio(false);
long n = 0;
long k = 0;
cin >> n >> k;
vector<int>arr(n);
vector<int> max1;
vector<int> min1;
for (int i = 0; i < n; i++)
{
cin >> arr[i];
}
int i = 0;
int j = 0;
j = k - 1;
int v = 0;
while (j<n)
{
/* long max = arr[v];
long min = arr[v];*/
int max = 0;
int min = 0;
/* max_element(arr.begin()+i, arr.end()+j,a);
min_element(arr.begin() + i, arr.end() + j, b);*/
/*for (int m = i+1; m <= j; m++)
{
if (arr[m] > max)
{
max = arr[m];
}
if (arr[m] < min)
{
min = arr[m];
}
long g = 0;
}*/
max = *max_element(arr.begin() + i, arr.begin() + j+1);
min = *min_element(arr.begin() + i, arr.begin() + j+1);
//printf("%d ", min);
cout << min << ' ';
max1.push_back(max);
//min1.push_back(min);
i++; j++; v++;
}
/*for (int i = 0; i < min1.size(); i++)
{
printf("%d ", min1[i]);
}*/
cout << '\n';
for (int i = 0; i < max1.size(); i++)
{
cout << max1[i] << ' ';
}
}
by Steve_xh @ 2023-12-14 12:39:00
@number2003 有没有一种可能,你正常写就能过了