QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#685322#9528. New Energy VehicleAPFLYWA 1ms3840kbC++171.1kb2024-10-28 18:50:512024-10-28 18:50:52

Judging History

This is the latest submission verdict.

  • [2024-10-28 18:50:52]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3840kb
  • [2024-10-28 18:50:51]
  • Submitted

answer

#include <bits/stdc++.h>

using namespace std;

#define int long long

#define dbg(x) cout << #x << " = " << x << endl

void solve() {
    int n, m; cin >> n >> m;

    int sum = 0;
    vector<int> ve(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> ve[i];
        sum += ve[i];
    }

    struct Node {
        int a, b;
    };
    vector<Node> se(m + 1);
    se[0].a = 0, se[0].b = 0;
    for (int i = 1; i <= m; i++) {
        cin >> se[i].a >> se[i].b;
    }

    int aa = 0, ans = 0;
    for (int i = 1; i <= m; i++) {
        int x = se[i].a - se[i - 1].a;
        if ((sum - x) < 0) {
            cout << se[i - 1].a + sum << '\n';
            return;
        }

        sum -= x;
        ans += x;

        if (ans >= ve[se[i].b]) {
            sum += ve[se[i].b];
            ans -= ve[se[i].b];
        }
        else {
            sum += ans;
            ans = 0;
        }
    }
    // cout << sum << '\n';
    cout << se[se.size() - 1].a + sum << '\n';
}

signed main() {
    cin.tie(nullptr)->ios::sync_with_stdio(false);

    int T = 1; cin >> T;
    while (T--) solve();

    return 0;
}

詳細信息

Test #1:

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

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

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'