QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#684270#9528. New Energy VehiclecarboxylBaseWA 1ms9740kbC++231.7kb2024-10-28 11:56:062024-10-28 11:56:07

Judging History

This is the latest submission verdict.

  • [2024-10-28 11:56:07]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 9740kb
  • [2024-10-28 11:56:06]
  • 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];
int b[2000000];
deque<int> q;

void solve()
{
    cin >> n >> m;
    for (int i = 1;i<n+1;i++){
        cin >> a[i];
        b[i] = a[i];
    }
    for (int i = 1;i<m+1;i++){
        cin >> x[i] >> t[i];
        q.push_back(t[i]);
    }
    for (int i = 1;i<=n;i++){
        q.push_back(i);
    }
    int pos = 0;
    for (int i = 1;i<=m;i++){
        //cout<<i<<endl;
        int delta = x[i] - pos;
        if (delta <= b[t[i]]){
            b[t[i]] = a[t[i]];
            pos = x[i];
            continue;
        }else{
            pos += b[t[i]];
            delta -= b[t[i]];
            b[t[i]] = 0;
        }
        // cout<<q.size()<<endl;
        while (!q.empty()&&delta){
            // cout<<q.front()<<"as"<<endl;
            if (b[q.front()] <= delta ){
                pos += b[q.front()];
                delta -= b[q.front()];
                b[q.front()] = 0;
                q.pop_front();
            }else{
                b[q.front()] -= delta;
                pos += delta;
                delta = 0;
            }
        }
        // cout<<pos<<" "<<delta<<endl;
        if (delta){
            break;
        }else{
            b[t[i]] = a[t[i]];
            // pos = x[i];
        }
    }
    for(int i = 1;i<=n;i++){
        pos += b[i];
    }
    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;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 9624kb

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

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:

9
11
4
11
1999999999
2000000000

result:

wrong answer 5th lines differ - expected: '999999999', found: '1999999999'