QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#692765#9528. New Energy VehiclelxlWA 1ms7680kbC++20807b2024-10-31 15:00:532024-10-31 15:01:01

Judging History

This is the latest submission verdict.

  • [2024-10-31 15:01:01]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 7680kb
  • [2024-10-31 15:00:53]
  • 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];
	}
	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]])continue;
		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: 1ms
memory: 7676kb

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

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'