-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11003.cpp
More file actions
41 lines (38 loc) · 669 Bytes
/
Copy path11003.cpp
File metadata and controls
41 lines (38 loc) · 669 Bytes
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
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
struct st
{
int x, idx;
};
bool operator<(st a, st b)
{
return a.x > b.x;
}
priority_queue<st> pq;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int L, N, input;
cin >> N >> L;
for (int i = 0; i < L; i++)
{
cin >> input;
pq.push({input, i});
cout << pq.top().x << " ";
}
for (int i = L; i < N; i++)
{
cin >> input;
pq.push({input, i});
while (pq.top().idx < i - L + 1)
{
pq.pop();
}
cout << pq.top().x << " ";
}
return 0;
}