QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#754635#9521. Giving Directions in HarbinANIG#WA 2ms12204kbC++141.3kb2024-11-16 15:27:302024-11-16 15:27:31

Judging History

你现在查看的是最新测评结果

  • [2024-11-16 15:27:31]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:12204kb
  • [2024-11-16 15:27:30]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+5;
int t,n,m,w[N],g[N],wz[N],p[N];
struct node{
    int bh,wz;
    friend bool operator<(node a,node b){
        return a.wz<b.wz;
    }
};
priority_queue<node>q;
vector<int>gs[N];
signed main(){
    cin>>t;
    while(t--){
        cin>>n>>m;
        for(int i=1;i<=n;i++)cin>>w[i],g[i]=w[i],gs[i].clear();
        for(int i=1;i<=m;i++)cin>>wz[i]>>p[i],gs[p[i]].push_back(i);
        for(int i=1;i<=n;i++)gs[i].push_back(m+1);
        for(int i=1;i<=n;i++){
          q.push({i,gs[i][0]});
        }
        int res=0;
        for(int i=1;i<=m;i++){
            int nw=wz[i]-wz[i-1];
            while(q.size()&&g[q.top().bh]<=nw){
                int x=q.top().bh;
                nw-=g[x];
                res+=g[x];
                g[x]=0;
                q.pop();
            }
            if(q.size()){
                int x=q.top().bh;
                g[x]-=nw;
                res+=nw;
                nw=0;
            }
            if(nw)break;
            if(q.size()&&q.top().bh==p[i])q.pop();
            g[p[i]]=w[p[i]];
            q.push({p[i],*upper_bound(gs[p[i]].begin(),gs[p[i]].end(),i)});
        }
        for(int i=1;i<=n;i++)res+=g[i];
        cout<<res<<"\n";
    }
}

详细

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 12204kb

input:

1
2
S 2
E 1

output:

0

result:

wrong answer Integer parameter [name=m] equals to 0, violates the range [1, 20] (test case 1)