QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#716912 | #9528. New Energy Vehicle | EDGE | WA | 0ms | 3716kb | C++20 | 721b | 2024-11-06 16:20:35 | 2024-11-06 16:20:36 |
Judging History
answer
#include<bits/stdc++.h>
#define LL long long
#define maxn 100010
using namespace std;
int t,n,m;
LL ans,sum,all;
int a[maxn],pos[maxn],id[maxn];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>t;
while(t--){
cin>>n>>m;
ans=0;pos[m+1]=0x7fffffff;sum=0;all=0;
for(int i=1;i<=n;i++) cin>>a[i],all+=a[i];
for(int i=1;i<=m;i++) cin>>pos[i]>>id[i];
for(int i=1;i<=m+1;i++){
if(pos[i]-pos[i-1]<=a[id[i]])
ans+=pos[i]-pos[i-1];
else{
ans+=a[id[i]];
sum+=(pos[i]-pos[i-1])-a[id[i]];
if(sum>all-a[id[i]]){
ans+=all;
}
sum-=a[id[i]];
}
}
cout<<ans<<endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3712kb
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: 3716kb
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 11 14 14 2000000001 2000000003
result:
wrong answer 3rd lines differ - expected: '4', found: '14'