您当前的位置: 首页 >  华为云

HeartFireY

暂无认证

  • 4浏览

    0关注

    334博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

2021CCPC华为云挑战赛

HeartFireY 发布时间:2021-08-22 22:17:03 ,浏览量:4

2021CCPC华为云挑战赛 A.对象存储调度问题

贪心问题,使用优先队列(大顶堆)存一下分条,然后从小的对象开始填充。如果碰到无法填充的情况直接输出"No",因为堆顶元素是堆里最大的,它装不下后面的也一样装不下。

#include 
using namespace std;

const int N = 1e5 + 10;
int a[N], b[N];

priority_queue q;

signed main(){
    int t = 0; cin >> t;
    while(t--){
        int n, m, flag = 1; cin >> n >> m;
        while (!q.empty()) q.pop();
        for (int i = 1; i > a[i];
    
        sort(a + 1, a + 1 + n);
        for (int i = 1, x; i > x;
            q.push(x);
        }
        for (int i = n; i; i--){
            int now = q.top(); q.pop();
            if (a[i] > now){
                cout             
关注
打赏
1662600635
查看更多评论
0.3178s