QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#718517#9528. New Energy Vehicle20225954#WA 1ms3592kbC++20928b2024-11-06 20:43:522024-11-06 20:43:53

Judging History

This is the latest submission verdict.

  • [2024-11-06 20:43:53]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3592kb
  • [2024-11-06 20:43:52]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr<<#x<<(x)<<"\n"
#define db1(x) cerr<<#x<<(x)<<" "
#define rep(i,a,b) for(auto i=(a);i<=(b);i++)
#define ll long long
const int N = 1e5+10;
int n,m;
ll x[N],id[N],a[N],na[N];
int cnt[N];
void solve(){
    ll now=0,res=0,fu=0;
    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>a[i];
    x[0]=0;
    for(int i=1;i<=m;i++){
        cin>>x[i]>>id[i];
        cnt[id[i]]++;
    }
    for(int i=1;i<=n;i++){
       res+=a[i];
    }
    int j;
    for(j=1;j<=m;j++){
        ll d=x[j]-x[j-1];
        if(fu+d>res)break;
        if(a[id[j]]>=fu+d){
            fu=0;
        }else if(a[id[j]]>=fu){
            fu=fu+d-a[id[j]];
        }else{
            fu=fu-a[id[j]]+d;
        }
    }
    j--;
    cout<<x[j]-fu+res<<endl;
}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int _ ;cin>>_;while(_--)solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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
4
11
999999999
2000000000

result:

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