跳到正文

学习·文化课

75ptsTLE求调

lucasaa约 3 分钟
原文
文章信息与版本

文章信息

收录
2026年1月16日
更新
2026年1月19日
篇幅
约 3 分钟

版本

  1. v1当前

题目传送门:P14962 LBA R2 一次买够

75ptspts curmx应该是mn蛋竹帛懒得改了。

各位神牛发发力!!!

C++
#include<iostream>
#include<algorithm>
#define int long long
using namespace std;
int n,m,curmx,ans,o,x,y,flag;
struct no{
    int v,w;
    bool f;
}a[1000001];
bool cmp(no q,no h){
    return q.w>h.w;
}
signed main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>a[i].v>>a[i].w;
        curmx=max(a[i].w,curmx);
    }
    for(int i=1;i<=n;i++)
        if(a[i].w==curmx)
            ans+=a[i].v,a[i].f=1;
    for(int i=1;i<=m;i++){
        cin>>o>>x>>y;
        if(o==1){
            a[i+n].v=x;
            a[i+n].w=y;
            if(y>=curmx){
                ans+=a[i+n].v;
                a[i+n].f=1;
            }
        }
        else{
            a[x].w=y;
            if(a[x].f==1){
                if(curmx>y){
                    curmx=a[x].w;
                    for(int j=1;j<=i+n;j++)
                        if(a[j].w>=curmx&&!a[j].f){
                            ans+=a[j].v;
                            a[j].f=1;
                        }
                }
            }
            else
                if(a[x].w>=curmx){
                    a[x].f=1;
                    ans+=a[x].v;
                }
        }
        cout<<ans<<endl;
    }
}
原文