QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#700323#9528. New Energy Vehiclesw7777#WA 1ms5788kbC++201.1kb2024-11-02 12:43:022024-11-02 12:43:03

Judging History

This is the latest submission verdict.

  • [2024-11-02 12:43:03]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 5788kb
  • [2024-11-02 12:43:02]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = 2e5+10;
struct chong{
    int dis;
    int x;
    bool operator < (const chong &b) const{
        return dis < b.dis;
    }
}chg[maxn];
int a[maxn];
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin>>t;
    while(t--){
        int n,m;
        cin>>n>>m;
        int ans = 0;
        for(int i = 1;i<=n;i++){
            cin>>a[i];
            ans += a[i];
        }
        for(int i = 1;i<=m;i++){
            cin>>chg[i].dis>>chg[i].x;
        }
        sort(chg+1,chg+m+1);
        int di = 0;
        int add = 0;
        for(int i = 1;i<=m;i++){
            int dis = chg[i].dis;
            int x= chg[i].x;
            //cout<<dis<<" "<<x<<" "<<a[x]<<endl;
            if(dis - di > a[x]){
                di += a[i];
                add += a[i];
                //cout<<di<<" "<<add<<endl;
            }
            else{
                add += dis - di;
                di = dis;
            }
            //cout<<di<<" "<<add<<endl;
        }
        cout<<ans+add<<endl;
    }
    
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 5788kb

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:

10
11
10
11
1999999998
2000000000

result:

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