-
Notifications
You must be signed in to change notification settings - Fork 67
/
ARRAYSUB.cpp
47 lines (41 loc) · 855 Bytes
/
ARRAYSUB.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <cassert>
#include <iomanip>
#include <ctime>
using namespace std;
const int me = 1000025;
int n, k;
int a[me];
multiset<int> s;
int main(){
//ios_base::sync_with_stdio(0);
//cin.tie(0);
scanf("%d", &n);
for(int i = 1; i <= n; i ++)
scanf("%d", &a[i]);
scanf("%d", &k);
for(int i = 1; i < k; i ++)
s.insert(a[i]);
for(int i = k; i <= n; i ++){
if(i > k)
s.erase(s.find(a[i - k]));
s.insert(a[i]);
printf("%d", *(--s.end()));
if(i < n)
putchar(' ');
}
putchar('\n');
return 0;
}