QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#697717#9528. New Energy VehiclelamkappaWA 0ms3644kbC++20928b2024-11-01 15:28:082024-11-01 15:28:08

Judging History

This is the latest submission verdict.

  • [2024-11-01 15:28:08]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3644kb
  • [2024-11-01 15:28:08]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
using i64 = long long;

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

    int T; cin >> T;
    while(T--){
        int n, m; cin >> n >> m;
        vector<i64> a(n);
        for(auto&x : a) cin >> x;
        vector<pair<int, int>> b(m);
        for(auto&[x, t] : b){
            cin >> x >> t; t--;
        }
        // sort(b.begin(), b.end());

        i64 usage = 0, ans = 0, sum = accumulate(a.begin(), a.end(), 0ll);
        int last = 0;
        for(auto[x, t] : b){
            auto d = x - last;
            usage += d;
            if(usage > sum){
                ans += (sum - (usage - d));
                break;
            }
            ans += d;
            usage -= min(usage, a[t]);
            last = x;
        }
        ans += max(0ll, sum - usage);
        cout << ans << '\n';
    }

    return 0;
}

詳細信息

Test #1:

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

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

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'