#include <stdio.h>
#include <queue>
using namespace std;
int data[100005];
priority_queue<int, vector<int>, greater<int> > q;
int main() {
int N, K;
scanf("%d %d", &N, &K);
for (int i = 0; i < N; i++) scanf("%d", &data[i]);
for (int i = 0; i < K; i++) q.push(data[i]);
for (int i = K; i < N; i++) {
q.push(data[i]);
printf("%d ", q.top());
q.pop();
}
while (!q.empty()) {
printf("%d ", q.top());
q.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 |
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 |
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 |
0 ms |
1988 KB |
Output is correct |
2 |
Correct |
0 ms |
2372 KB |
Output is correct |
3 |
Correct |
25 ms |
1732 KB |
Output is correct |
4 |
Correct |
34 ms |
1600 KB |
Output is correct |
5 |
Correct |
29 ms |
1988 KB |
Output is correct |
6 |
Correct |
0 ms |
1732 KB |
Output is correct |
7 |
Correct |
28 ms |
1600 KB |
Output is correct |
8 |
Correct |
0 ms |
1988 KB |
Output is correct |
9 |
Correct |
54 ms |
1732 KB |
Output is correct |
10 |
Correct |
32 ms |
1600 KB |
Output is correct |
11 |
Correct |
41 ms |
1988 KB |
Output is correct |
12 |
Correct |
0 ms |
1600 KB |
Output is correct |
13 |
Correct |
10 ms |
1600 KB |
Output is correct |
14 |
Correct |
0 ms |
1600 KB |
Output is correct |
15 |
Correct |
46 ms |
1732 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
50 ms |
2372 KB |
Output is correct |
2 |
Correct |
41 ms |
1732 KB |
Output is correct |
3 |
Correct |
35 ms |
1600 KB |
Output is correct |
4 |
Correct |
25 ms |
1600 KB |
Output is correct |
5 |
Correct |
34 ms |
1732 KB |
Output is correct |
6 |
Correct |
20 ms |
1988 KB |
Output is correct |
7 |
Correct |
35 ms |
1988 KB |
Output is correct |
8 |
Correct |
0 ms |
1600 KB |
Output is correct |
9 |
Correct |
0 ms |
1732 KB |
Output is correct |
10 |
Correct |
33 ms |
1732 KB |
Output is correct |
11 |
Correct |
0 ms |
1988 KB |
Output is correct |
12 |
Correct |
38 ms |
1600 KB |
Output is correct |
13 |
Correct |
0 ms |
1600 KB |
Output is correct |
14 |
Correct |
11 ms |
1600 KB |
Output is correct |
15 |
Correct |
48 ms |
1988 KB |
Output is correct |