QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#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;
}
Details
Tip: Click on the bar to expand more detailed information
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