QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#683316#9528. New Energy VehiclecarboxylBase#WA 0ms7752kbC++231.1kb2024-10-27 20:05:292024-10-27 20:05:29

Judging History

This is the latest submission verdict.

  • [2024-10-27 20:05:29]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 7752kb
  • [2024-10-27 20:05:29]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;

int n,m;
int a[2000000];
int x[2000000];
int t[2000000];

void solve()
{
    cin >> n >> m;
    int sum = 0;
    for (int i = 1;i<n+1;i++){
        cin >> a[i];
        sum += a[i];
    }
    for (int i = 1;i<m+1;i++){
        cin >> x[i] >> t[i];
    }
    int daikuan = 0;
    int pos = 0;
    for (int i = 1;i<=m;i++){
        if (sum-daikuan>x[i]-pos){
            daikuan += x[i] - pos;
            if (daikuan >= a[t[i]]){
                daikuan -= a[t[i]];
            }else{
                daikuan = 0;
            }
            // cout<<"ys"<<endl;
            pos = x[i];
        }else{
            pos += sum - daikuan;
            daikuan = sum;
            break;
        }
    }
    pos += sum - daikuan;
    cout<<pos<<endl;
    return;
}
signed main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0), cin.tie(nullptr), cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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:

6
11
4
11
999999999
1000000000

result:

wrong answer 1st lines differ - expected: '9', found: '6'