QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#697096#9528. New Energy VehiclepanelopeWA 1ms7728kbC++171.6kb2024-11-01 10:23:512024-11-01 10:23:52

Judging History

This is the latest submission verdict.

  • [2024-11-01 10:23:52]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 7728kb
  • [2024-11-01 10:23:51]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;

int n,m;
struct ty{
    long long x,cur;
};
struct node{
    long long i,t;
    bool operator < (const node &b) const {
        return t > b.t;
    }
};
ty a[100010];
long long x[100010],t[100010];
long long nxt[100010];
long long c[100010];
priority_queue<node> q;
int main(){
    int T;
    cin >> T;
    while(T--){
        cin >> n >> m;
        long long ans = 0;
        for(int i=1; i<=n; i++)
        {    
            cin >> a[i].x;
            a[i].cur = a[i].x;
            ans += a[i].x;
            q.push({i,(long long)1e18+1});
        }
        for(int i=1; i<=m; i++)
        {
            cin >> x[i] >> t[i];
            q.push({t[i],x[i]});
        }
        for(int i=1; i<=n; i++)
            c[i] = 1e18;
        for(int i=m; i>=1; i--){
            nxt[i] = c[t[i]];
            c[t[i]] = i;
        }
        for(int i=1; i<=n; i++)
            q.push({i,c[i]});
        for(int i=1; i<=m; i++){
            long long p = x[i]-x[i-1];
            while(p && !q.empty()){
                node cur = q.top();
                q.pop();
                if(a[cur.i].cur>=p){
                    a[cur.i].cur -= p;
                    p = 0;
                    if(cur.i!=t[i])q.push(cur);
                }
                else{
                    p -= a[cur.i].cur;
                    a[cur.i].cur = 0;
                }
            }
            if(p)break;
            ans += a[t[i]].x - a[t[i]].cur;
            a[t[i]].cur = a[t[i]].x;
            q.push({t[i],nxt[i]});
        }
        while(q.size())q.pop();
        cout << ans << endl;
    }
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 7728kb

input:

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

output:

12
8

result:

wrong answer 2nd lines differ - expected: '9', found: '8'