QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#692839#9528. New Energy VehiclelxlWA 1ms5672kbC++20871b2024-10-31 15:07:022024-10-31 15:07:10

Judging History

This is the latest submission verdict.

  • [2024-10-31 15:07:10]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 5672kb
  • [2024-10-31 15:07:02]
  • Submitted

answer

#define _CRT_SECURE_NO_WARNINGS 1
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAX = 0x3f3f3f3f;
const ll mod = 998244353;
const ll N = 2e5 + 10;


ll a[N] = {}, x[N] = {}, t[N] = {};
void solve() {
	ll sum = 0;
	ll n, m; cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> a[i]; sum += a[i];
	}
	ll tot = sum;
	for (int i = 1; i <= m; i++) cin >> x[i] >> t[i];
	for (int i = 1; i <= m; i++) {
		int dis = x[i] - x[i - 1];
		if (dis <= a[t[i]]) {
			if (tot > sum)sum += min(tot - sum, a[t[i]]);
		}
		else if (dis > a[t[i]] && dis < sum) {
			sum -= dis - a[t[i]];
		}
		else if (dis > sum) {
			cout << x[i - 1] + sum;
			return;
		}
	}
	cout << x[m] + sum << endl;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int t = 1;
	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: 5608kb

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: 1ms
memory: 5672kb

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:

13
11
411
9999999992000000000

result:

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