P1230 智力大冲浪

Miku

解提示思路一定要清醒,想好了再干。

别直接下笔,有思路吗,没思路写什么

--scz

被这个题卡了1h 我还是太弱了

太弱了

思路本身好想,从后往前扫,能搞就干,先玩最大,同时间扔一块

$color{red}{但是我写了啥}$

#include<iostream>
#include<algorithm> 
#include<queue>
#include<cstdio>
using namespace std;
struct gam{
    int m;
    int t;
}g[1000000];
int m;
int now;
priority_queue <int>q;
int n;
int last;
int d;
int co;
int wor;
bool cmp(gam x,gam y){
    if(x.t==y.t)
    return x.m>y.m;
    return x.t<y.t;
}
int ans;
int main(){
    scanf("%d%d",&m,&n);
    for(int i=1;i<=n;++i){
        scanf("%d",&g[i].t);
    }
    for(int i=1;i<=n;++i){
        scanf("%d",&g[i].m);
        wor+=g[i].m;
    }
    sort(g+1,g+n+1,cmp);
    now=g[n].t;
    last=now;//上一个任务剩余时间 
    for(int i=n;i>=1;--i){
        q.push(g[i].m);
        while(g[i].t==g[i-1].t){
            i--;
            q.push(g[i].m);
        }
        while(last>g[i-1].t&&last>0){
            if(!q.empty()){
            co+=q.top();
            q.pop();
            last--;
            }
            else{
                last=g[i-1].t;
                break;
            }
        }
    };
    cout<<m-wor+co;
    return 0;
}
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇