QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#679366#9528. New Energy Vehicleucup-team134#WA 0ms4136kbC++17926b2024-10-26 17:27:592024-10-26 17:27:59

Judging History

This is the latest submission verdict.

  • [2024-10-26 17:27:59]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 4136kb
  • [2024-10-26 17:27:59]
  • Submitted

answer

#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ld long double
#define li __int128

using namespace std;

mt19937 rng(time(NULL));

int main()
{
	ios;
	int t;
	cin >> t;
	while(t--){
		int n,m;
		cin >> n >> m;
		ll b=0;
		vector<int> a(n);
		for(int i=0;i<n;i++){
			cin >> a[i];
			b+=a[i];
		}
		ll potrosio=0;
		int p=0;
		bool done=0;
		for(int i=0;i<m;i++){
			int x,t;
			cin >> x >> t;
			if(done)continue;
			int d=x-p;
			if(potrosio+d>b){
				printf("%lld\n",p+b-potrosio);
				done=1;
			}
			potrosio+=d;
			int ref=a[t-1];
			potrosio=max(0LL,potrosio-ref);
			p=x;
		}
		if(!done){
			printf("%lld\n",p+b-potrosio);
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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'