QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#683267#9528. New Energy VehicleEBeasonWA 2ms11224kbC++171.2kb2024-10-27 19:47:492024-10-27 19:47:49

Judging History

This is the latest submission verdict.

  • [2024-10-27 19:47:49]
  • Judged
  • Verdict: WA
  • Time: 2ms
  • Memory: 11224kb
  • [2024-10-27 19:47:49]
  • Submitted

answer

// #pragma GCC optimize(1, 2, 3, "Ofast", "inline")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define int ll
#define ls p << 1
#define rs p << 1 | 1
#define lowbit(x) ((x) & (-x))
#define endl '\n'
#define ld long double

using PII = pair<int, int>;
#define MULTI_CASES
const int MaxN = 1e6 + 100;
const int INF = 1e9;
int T, N, M, K;
vector<int> a(MaxN);
inline void Solve() {
    cin >> N >> M;
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        cin >> a[i];
        ans += a[i];
    }
    int last = 0;
    vector<PII> b(M + 1);
    for (int i = 1; i <= M; i++) {
        auto &[x, y] = b[i];
        cin >> x >> y;
        if (ans < x) {
            continue;
        }
        int now = x - b[i - 1].first;
        if (now >= a[y]) {
            last += now - a[y];
            ans += a[y];
        } else {
            last += now;
            int p = min(last, a[y]);
            ans += p;
            last -= p;
        }
    }
    cout << ans << endl;
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	srand(time(NULL));
#ifdef MULTI_CASES
	int T;
	cin >> T;
	while (T--)
#endif
		Solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 11112kb

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

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'