QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#689908 | #9528. New Energy Vehicle | Aliemo | WA | 1ms | 5744kb | C++14 | 1.3kb | 2024-10-30 19:10:19 | 2024-10-30 19:10:20 |
Judging History
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 = max(x[i] - a[y[i]], x[i] - x[i - 1]);
// cout << te
if (res >= x[i]) {
res -= temp;
res += min(temp, a[y[i]]);
cnt = x[i];
ans = max(cnt + res, ans);
}
}
ans = max(ans, cnt + res);
cout << ans << "\n";
}
}
/*
1
1 1
1000000000
1000000000 1
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5744kb
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: 5656kb
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:
8 11 4 11 999999999 2000000000
result:
wrong answer 1st lines differ - expected: '9', found: '8'