QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#61928 | #4500. Loop | qinjianbin | AC ✓ | 223ms | 6704kb | C++17 | 745b | 2022-11-15 22:58:52 | 2022-11-15 22:58:54 |
Judging History
answer
#include<bits/stdc++.h>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define _for(i, a, b) for(int i = (a); i <= (b); i++)
using namespace std;
const int N = 3e5 + 10;
int st[N], top, n, k;
int main()
{
int T; scanf("%d", &T);
while(T--)
{
top = 0;
scanf("%d%d", &n, &k);
priority_queue<int> q;
_for(i, 1, n)
{
int x; scanf("%d", &x);
while(k && top && x > st[top])
{
k--;
q.push(st[top--]);
}
st[++top] = x;
}
_for(i, 1, top)
{
while(!q.empty() && q.top() > st[i])
{
printf("%d ", q.top());
q.pop();
}
printf("%d ", st[i]);
}
while(!q.empty())
{
printf("%d ", q.top());
q.pop();
}
puts("");
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 223ms
memory: 6704kb
input:
100 300000 300000 1 1 300000 153456 153456 1 153456 153456 300000 1 300000 1 300000 300000 300000 1 300000 300000 300000 1 300000 300000 300000 300000 300000 1 300000 153456 300000 1 153456 153456 1 300000 153456 300000 300000 1 300000 1 1 153456 153456 300000 153456 153456 153456 153456 1 300000 30...
output:
300000 300000 300000 300000 300000 300000 300000 300000 300000 300000 300000 300000 300000 300000 300000 300000 300000 300000 300000 300000 300000 300000 300000 300000 300000 300000 300000 300000 300000 300000 300000 300000 300000 300000 300000 300000 300000 300000 300000 300000 300000 300000 300000...
result:
ok 100 lines