最快最长
2023-08-18 18:15:21
发布于:内蒙古
16阅读
0回复
0点赞
*2023-08-18
恭喜你,提交通过!
执行用时:22ms
内存消耗:1.97MB
击败了100.00%的用户
击败了0.00%的用户
#include <bits/stdc++.h>
using namespace std;
priority_queue<int> ma_hp;
priority_queue<int, vector<int>, greater<int> > mi_hp;
int n, w, now, num;
void qwq()
{
if (mi_hp.size()<now)
{
mi_hp.push(ma_hp.top());
ma_hp.pop();
}
if (mi_hp.size() > now)
{
ma_hp.push(mi_hp.top());
mi_hp.pop();
}
}
void push(int num)
{
if (num >= ma_hp.top()) mi_hp.push(num);
else ma_hp.push(num);
qwq();
}
int main()
{
scanf("%d%d", &n, &w);
ma_hp.push(0);
for (int p = 1; p <= n; p++)
{
now=max(1,p*w/100);
scanf("%d", &num);
push(num);
printf("%d ", mi_hp.top());
}
return 0;
}
这里空空如也
有帮助,赞一个