QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#685234#9528. New Energy VehiclezcxWA 0ms3684kbC++14569b2024-10-28 18:23:502024-10-28 18:23:52

Judging History

This is the latest submission verdict.

  • [2024-10-28 18:23:52]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3684kb
  • [2024-10-28 18:23:50]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,m;
int a[100010],x[100010],w[100010];
const int INF=1e9;
signed main(){
	int t;
	cin>>t;
	while(t--){
		cin>>n>>m;
		int sum=0;
		for(int i=0;i<n;i++){
			cin>>a[i];
			sum+=a[i];
		}
		x[0]=0,w[0]=0;
		for(int i=1;i<=m;i++){
			cin>>x[i]>>w[i];
		}
		int ans=0;
		for(int i=1;i<=m;i++){
			sum-=x[i]-x[i-1];
			if(sum<=0) break;
			if(x[i]-x[i-1]>a[w[i]]){
				sum+=a[w[i]];
			}
			else sum+=((x[i]-x[i-1]));
			ans=max(ans,x[i]+sum);
		}
		cout<<ans<<endl;
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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:

0
10
0
10
0
0

result:

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