QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#689321#9528. New Energy Vehicleyingling#WA 1ms3672kbC++201.7kb2024-10-30 16:22:572024-10-30 16:22:57

Judging History

This is the latest submission verdict.

  • [2024-10-30 16:22:57]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3672kb
  • [2024-10-30 16:22:57]
  • Submitted

answer

#include <bits/stdc++.h>
#define endl "\n"
#define int long long
using namespace std;

typedef pair<int, int> PII;

void solve()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n + 7);
    vector<PII> pd;
    vector<int> cnt(n + 7);
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    auto b = a;
    for (int i = 1; i <= m; i++) {
        int x, t;
        cin >> x >> t;
        pd.push_back({x, t});
        cnt[t] ++;
    }
    int now = 0, idx = 0, sum = 0;
    for (int i = 1; i <= n ; i ++) {
        if (!cnt[i])
            sum += a[i];
    }
    int idxr = 0;
    while (idx < m) {
        while (1) {
            if (idxr < m) {
                if (now + a[pd[idxr].second] < pd[idx].first)
                    now += a[pd[idxr].second], a[pd[idxr].second] = 0;
                else {
                    a[pd[idxr].second] -= pd[idx].first - now;
                    now = pd[idx].first;
                    break;
                }
            }
            else {
                if (now + sum < pd[idx].first) {
                    now += sum;
                    cout << now << endl;
                    return;
                }
                else {
                    sum -= pd[idx].first - now;
                    now = pd[idx].first;
                    break;
                }
            }
            idxr ++;
        }
        a[pd[idx].second] = b[pd[idx].second];
        cnt[pd[idx].second] --;
        if (!cnt[pd[idx].second])
            sum += a[pd[idx].second];
        idx ++;
    }
    cout << now + sum << endl;
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int T = 1;
    cin >> T;
    while (T--)
        solve();
    return 0;
}

詳細信息

Test #1:

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

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

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
12
4
12
999999999
2000000000

result:

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