QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#721315#9528. New Energy Vehiclezzfs#RE 0ms3608kbC++17851b2024-11-07 15:49:082024-11-07 15:49:08

Judging History

This is the latest submission verdict.

  • [2024-11-07 15:49:08]
  • Judged
  • Verdict: RE
  • Time: 0ms
  • Memory: 3608kb
  • [2024-11-07 15:49:08]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5+5000;
int a[N];
unordered_map<int,int> p;
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;
    for(int i=1;i<=m;i++){
        cin>>x>>y;
        if(x-len>sum){
            cout<<len+sum<<'\n';
            return ;
        }
        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: 3608kb

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
Runtime Error

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
24

result: