some programs!!
This commit is contained in:
1 parent
ed054247d5
commit
71f1022dea
38 files changed
+1037
-281
No files matched your search
@@ -0,0 +1,38 @@
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <queue>
|
||||
|
||||
constexpr size_t MAX_N = 1e6 + 1;
|
||||
|
||||
|
||||
int n, window_length;
|
||||
int nums[MAX_N], max_nums[MAX_N], min_nums[MAX_N];
|
||||
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
std::cin.tie(nullptr);
|
||||
|
||||
std::cin >> n >> window_length;
|
||||
if (window_length > n) { window_length = n; }
|
||||
for (int i = 0; i < n; i++) {
|
||||
std::cin >> nums[i];
|
||||
}
|
||||
|
||||
for (int i = 0; i + window_length <= n; i++) {
|
||||
max_nums[i] = *std::max_element(nums + i, nums + i + window_length);
|
||||
min_nums[i] = *std::min_element(nums + i, nums + i + window_length);
|
||||
}
|
||||
|
||||
for (int i = 0; i <= n - window_length; i++) {
|
||||
std::cout << min_nums[i] << " ";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
for (int i = 0; i <= n - window_length; i++) {
|
||||
std::cout << max_nums[i] << " ";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user