QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#709891#9528. New Energy Vehicleghosh__#WA 3ms72108kbC++231.6kb2024-11-04 17:19:202024-11-04 17:19:27

Judging History

This is the latest submission verdict.

  • [2024-11-04 17:19:27]
  • Judged
  • Verdict: WA
  • Time: 3ms
  • Memory: 72108kb
  • [2024-11-04 17:19:20]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define int long long
const int maxn = 1e5 + 5;
int n, m, a[maxn], x[maxn], t[maxn], b[maxn];
queue<int> q[maxn];
void Solve() {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) while (q[i].size()) q[i].pop();
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        b[i] = a[i];
    }
    for (int i = 1; i <= m; i++) {
        cin >> x[i] >> t[i];
        q[t[i]].push(x[i]);
    }
    int cur = 0;
    set<pair<int,int>> s;
    for (int i = 1; i <= n; i++) {
        if (q[i].size()) {
            s.insert({q[i].front(), i});
            q[i].pop();
        }
    }
    int now = 0;
    while (now < m) {
        int res = x[now + 1] - cur;
        while (res) {
            if (s.empty()) break;
            int id = s.begin() -> second;
            int val = min(res, a[id]);
            res -= val;
            a[id] -= val;
            cur += val;
            if (!a[id]) s.erase(s.begin());
        }
        if (res) break;
        now++;
        a[t[now]] = b[t[now]];
        int col = t[now];
        if (s.find({x[now], t[now]}) != s.end()) s.erase({x[now], t[now]});
        if (q[col].size()) {
            s.insert({q[col].front(), col});
            q[col].pop();
        }
    }
    for (int i = 1; i <= n; i++) cur += a[i];
    cout << cur << endl;
}
signed main() {
    //freopen("in", "r", stdin);
    //freopen("out", "w", stdout);
    int T;
    cin >> T;
    while (T--){
        Solve();
    }
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 72108kb

input:

2
3 1
3 3 3
8 1
2 2
5 2
1 2
2 1

output:

9
9

result:

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