QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#788028#9528. New Energy VehicleCSQ#RE 0ms3564kbC++20843b2024-11-27 15:39:532024-11-27 15:39:55

Judging History

This is the latest submission verdict.

  • [2024-11-27 15:39:55]
  • Judged
  • Verdict: RE
  • Time: 0ms
  • Memory: 3564kb
  • [2024-11-27 15:39:53]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sz(a) (int)(a.size())

signed main()
{
    int t;
    cin>>t;
    while(t--){
        int n, m;
        cin >> n >> m;
        vector<int> bat(n);
        for ( int& a: bat ) cin >> a;
        int prev = 0;
        int oob = 0;
        int remain = 0;
        for ( int& a: bat ) remain += a;
        int x, t;
        while ( m-- ) {
            cin >> x >> t; t--;
            remain -= x-prev;
            if ( remain < 0 ) {
                cout << x+remain << '\n';
                break;
            }
            oob += x-prev;
            int charge = min(bat[t], oob);
            remain += charge;
            oob -= charge;
            prev = x;
            if ( m == 0 ) cout << prev+remain << '\n';
        }
    }


}

詳細信息

Test #1:

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

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:

10
11
4
24

result: