QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#689862#9528. New Energy VehicleAliemoRE 0ms5696kbC++141.3kb2024-10-30 18:58:362024-10-30 18:58:36

Judging History

This is the latest submission verdict.

  • [2024-10-30 18:58:36]
  • Judged
  • Verdict: RE
  • Time: 0ms
  • Memory: 5696kb
  • [2024-10-30 18:58:36]
  • Submitted

answer

/**
*  Author: Aliemo
*  Data:
*  Problem:
*  Time: O()
*/
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>

#define int long long
#define rr register

#define inf 1e9
#define MAXN 200010
#define MAXM 510

#define lson rt << 1
#define rson rt << 1 | 1

using namespace std;

inline int read() {
	int s = 0, f = 0;
	char ch = getchar();
	while (!isdigit(ch)) f |= ch == '-', ch = getchar();
	while (isdigit(ch)) s = s * 10 + (ch ^ 48), ch = getchar();
	return f ? -s : s;
}

void print(int x) {
	if (x < 0) putchar('-'), x = -x;
	if (x > 9) print(x / 10);
	putchar(x % 10 + 48);
}

int T, n, m, ans, res, cnt;

int a[MAXN], x[MAXN], y[MAXN];

signed main() {
	T = read();
	while (T--) {
		n = read(), m = read();
		res = 0;
		for (int i = 1; i <= n; i++) {
			a[i] = read();
			res += a[i];
		}
		ans = res;cnt = 0;
		for (int i = 1; i <= m; i++) {
			x[i] = read(), y[i] = read();
			int temp = x[i] - max(a[y[i]], x[i - 1]);
			if (res >= x[i]) {
				res -= temp;
				res += min(temp, y[a[i]]);
				cnt = x[i];
				ans = max(cnt + res, ans);
			}
		}
		ans = max(ans, cnt + res);
		cout << ans << "\n";
	}
}

/*

2
3 1
3 3 3
8 1
1
2 2
5 2
1 2
2 1

*/

詳細信息

Test #1:

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

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
Runtime Error

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:


result: