#include <cstdio>
#include <queue>
using namespace std;
int n, k, a[100005];
priority_queue<int,vector<int>,greater<int> > pq;
int main(){
scanf("%d %d",&n,&k);
for (int i=0; i<n; i++) {
scanf("%d",&a[i]);
}
for (int i=0; i<k; i++) {
pq.push(a[i]);
}
for (int i=0; i<n; i++) {
if(i + k < n){
pq.push(a[i + k]);
}
printf("%d ",pq.top());
pq.pop();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1600 KB |
Output is correct |
2 |
Correct |
0 ms |
1600 KB |
Output is correct |
3 |
Correct |
0 ms |
1600 KB |
Output is correct |
4 |
Correct |
0 ms |
1600 KB |
Output is correct |
5 |
Correct |
0 ms |
1600 KB |
Output is correct |
6 |
Correct |
0 ms |
1600 KB |
Output is correct |
7 |
Correct |
0 ms |
1600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1600 KB |
Output is correct |
2 |
Correct |
0 ms |
1600 KB |
Output is correct |
3 |
Correct |
0 ms |
1600 KB |
Output is correct |
4 |
Correct |
0 ms |
1600 KB |
Output is correct |
5 |
Correct |
1 ms |
1600 KB |
Output is correct |
6 |
Correct |
0 ms |
1600 KB |
Output is correct |
7 |
Correct |
0 ms |
1600 KB |
Output is correct |
8 |
Correct |
0 ms |
1600 KB |
Output is correct |
9 |
Correct |
0 ms |
1600 KB |
Output is correct |
10 |
Correct |
0 ms |
1600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
1988 KB |
Output is correct |
2 |
Correct |
0 ms |
1600 KB |
Output is correct |
3 |
Correct |
29 ms |
1732 KB |
Output is correct |
4 |
Correct |
40 ms |
1732 KB |
Output is correct |
5 |
Correct |
0 ms |
2372 KB |
Output is correct |
6 |
Correct |
0 ms |
1600 KB |
Output is correct |
7 |
Correct |
0 ms |
1988 KB |
Output is correct |
8 |
Correct |
0 ms |
1600 KB |
Output is correct |
9 |
Correct |
47 ms |
1732 KB |
Output is correct |
10 |
Correct |
40 ms |
1600 KB |
Output is correct |
11 |
Correct |
38 ms |
1988 KB |
Output is correct |
12 |
Correct |
0 ms |
1600 KB |
Output is correct |
13 |
Correct |
45 ms |
1988 KB |
Output is correct |
14 |
Correct |
36 ms |
1600 KB |
Output is correct |
15 |
Correct |
37 ms |
1732 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
1988 KB |
Output is correct |
2 |
Correct |
35 ms |
1988 KB |
Output is correct |
3 |
Correct |
32 ms |
1732 KB |
Output is correct |
4 |
Correct |
38 ms |
1600 KB |
Output is correct |
5 |
Correct |
38 ms |
1988 KB |
Output is correct |
6 |
Correct |
63 ms |
2372 KB |
Output is correct |
7 |
Correct |
41 ms |
1600 KB |
Output is correct |
8 |
Correct |
0 ms |
1600 KB |
Output is correct |
9 |
Correct |
0 ms |
1600 KB |
Output is correct |
10 |
Correct |
45 ms |
1988 KB |
Output is correct |
11 |
Correct |
0 ms |
1732 KB |
Output is correct |
12 |
Correct |
51 ms |
1732 KB |
Output is correct |
13 |
Correct |
38 ms |
1600 KB |
Output is correct |
14 |
Correct |
37 ms |
1600 KB |
Output is correct |
15 |
Correct |
32 ms |
1732 KB |
Output is correct |