QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#696612#9528. New Energy VehiclepanelopeWA 1ms5648kbC++171.6kb2024-10-31 23:49:412024-10-31 23:49:42

Judging History

This is the latest submission verdict.

  • [2024-10-31 23:49:42]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 5648kb
  • [2024-10-31 23:49:41]
  • Submitted

answer

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

int n,m;
struct ty{
    long long x,t,cur;
    int i;
    bool operator > (const ty &b) const{
        return t > b.t;
    }
};
ty a[100010];
long long x[100010],t[100010];
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;
            a[i].i = i;
            ans += a[i].x;
        }
        priority_queue<ty,vector<ty>,greater<ty>> q;
        for(int i=1; i<=m; i++)
        {
            cin >> x[i] >> t[i];
            a[t[i]].t = x[i];
            q.push(a[i]);
        }
        for(int i=1; i<=n; i++)
        {
            if(a[i].t == 0)
            {
                a[i].t = 1e9+1;
                q.push(a[i]);
            }

        }
        for(int i=1; i<=m; i++){
            long long p = 0;
            while(p < x[i]-x[i-1] && !q.empty()){
                ty cur = q.top();
                q.pop();
                long long l = x[i]-x[i-1] - p;
                if(cur.cur>=l){
                    a[cur.i].cur -= l;
                    p += l;    
                }
                else{
                    p += cur.cur;
                    a[cur.i].cur = 0;
                }
                //cout << cur.i <<' ' <<a[cur.i].cur << endl;
            }
            if(p!=x[i]-x[i-1])break;
            ans += a[t[i]].x - a[t[i]].cur;
            a[t[i]].cur = a[t[i]].x;
            a[t[i]].t = 1e9+1;
            q.push(a[t[i]]);
        }
        cout << ans << endl;
    }
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 5648kb

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: -100
Wrong Answer
time: 0ms
memory: 3608kb

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:

8
11
4
11
999999999
2000000000

result:

wrong answer 1st lines differ - expected: '9', found: '8'