QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#722715#9528. New Energy VehiclewangwxWA 54ms10224kbC++142.0kb2024-11-07 20:00:362024-11-07 20:00:38

Judging History

This is the latest submission verdict.

  • [2024-11-07 20:00:38]
  • Judged
  • Verdict: WA
  • Time: 54ms
  • Memory: 10224kb
  • [2024-11-07 20:00:36]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mxn=1e5+7,mxm=5e5+7;;
int n,m,a[mxn],x[mxn],t[mxn],c[mxn];
int T,in[mxn],vis[mxn];
struct ST{
    int dis,id;
    bool operator<(const ST& other)const{
        // if(c[other.id]==0 && c[id]>0) return false;
        if(c[id]==0 && c[other.id]>0) return true;
        if(c[other.id]==0 && c[id]>0) return false;
        return dis>other.dis;
    }
};
signed main(){   
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin>>T;
    while(T--){
        priority_queue<ST> q;
        cin>>n>>m;
        for(int i=1;i<=n;i++) cin>>a[i],c[i]=a[i],vis[i]=0;
        for(int i=1;i<=m;i++){
            cin>>x[i]>>t[i];
            q.push({x[i],t[i]});
            vis[t[i]]+=1;
            in[t[i]]=1;
        }
        // cout<<q.top().dis<<'\n';
        int tmp=0;
        for(int i=1;i<=n;i++) if(!vis[i]) tmp+=a[i];
        // cout<<tmp<<' ';
        int now=0,ans=0,fg=1,to_cnt=0;
        while(!q.empty()){
            // int to=q.top().dis;
            int to=x[++to_cnt];
            int y=t[to_cnt];
            while(now<to){
                while(q.top().dis<=now) q.pop();
                int x=q.top().id;
                int px=q.top().dis;
                if(c[x]==0){
                    int dx=min(tmp,to-now);
                    now+=dx;
                    tmp-=dx;
                    break;
                }
                int dx=min(to-now,c[x]);
                c[x]-=dx;
                if(c[x]==0) 
                    q.pop(),
                    q.push({px,x});
                // if(c[x]==0) in[x]=0;
                now+=dx;
            }
            if(now<to)break;
            c[y]=a[y];
            while(!q.empty() && q.top().dis<=now)q.pop();
            vis[y]--;
            if(vis[y]==0) tmp+=c[y];
            while(!q.empty() && q.top().dis<=now)q.pop();
        }
        // cout<<now<<' '<<tmp<<' ';
        now+=tmp;
        cout<<now<<'\n';
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 5664kb

input:

2
3 1
3 3 3
8 1
2 2
5 2
1 2
2 1

output:

12
9

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 1ms
memory: 5588kb

input:

6
3 2
2 2 2
6 1
7 1
2 2
3 3
2 1
6 2
2 3
2 2
5 1
7 2
9 1
2 2
3 3
2 1
6 2
1 1
999999999
1000000000 1
1 1
1000000000
1000000000 1

output:

9
11
4
11
999999999
2000000000

result:

ok 6 lines

Test #3:

score: -100
Wrong Answer
time: 54ms
memory: 10224kb

input:

10
230 8042
599 1039 69 1011 1366 824 14117 1523 806 5002 332 55 3769 996 359 1040 255 1135 3454 3609 6358 2509 3695 8785 3890 1304 3394 14611 33 89 2245 508 22 1043 10411 628 1279 714 903 585 7413 5099 845 148 4689 2110 8683 1613 143 3263 2599 110 244 3297 4742 1571 425 1822 15692 572 9397 328 1691...

output:

1543020
1578939
1526016
1527381
1547404
1564631
879611
1548178
1011090
1002127

result:

wrong answer 7th lines differ - expected: '1051729', found: '879611'