QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#721365#9528. New Energy Vehiclezzfs#WA 0ms3632kbC++17884b2024-11-07 15:57:072024-11-07 15:57:08

Judging History

This is the latest submission verdict.

  • [2024-11-07 15:57:08]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3632kb
  • [2024-11-07 15:57:07]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+5;
int a[N];
int p[N];
void solve()
{
    int n,m;
    cin>>n>>m;
    ll sum = 0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum += a[i];
        p[i] = 0;
    }
    ll len = 0;
    ll  x;
    int y;
    int flag = 1;
    for(int i=1;i<=m;i++){
        cin>>x>>y;
        if(x-len>sum){
            cout<<len+sum<<'\n';
            flag = 0;
        }
        if(flag == 0)continue;
        ll acm = a[y] - x + p[y];
        if(acm<0)acm = 0;
        ll res = x - len - acm;
        if(res>0){
            sum-=res;
            sum+=a[y];
        }
        //sum+=a[y];
        p[y] = x;
        len = x;
    }
    cout<<x+sum<<"\n";
    return ;
}

int main()
{
    int t;
    cin >> t;
    while (t--)
        solve();

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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
13
4
4
4
13
13
999999999
1999999999
2000000000

result:

wrong answer 2nd lines differ - expected: '11', found: '13'