QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#678950#9528. New Energy Vehicleucup-team4975#WA 0ms3592kbC++231.8kb2024-10-26 16:30:322024-10-26 16:30:33

Judging History

This is the latest submission verdict.

  • [2024-10-26 16:30:33]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3592kb
  • [2024-10-26 16:30:32]
  • Submitted

answer

#include <bits/stdc++.h>
#define el '\n'
using namespace std;
using ll = long long;
using PII = pair<int, int>;
void solve() 
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n + 1, 0), t(n + 1, 0);
    vector<int> now(n + 1, 0), p(n + 1, 0), nxt(n + 1, n + 1);
    for (int i =1 ;i <= n; i++) {
        cin >> a[i];
    }
    now = a;
    vector<vector<int>> pl(n + 1);
    vector<int> tmp(n + 1);
    for (int i = 1;i <= m; i++) {
        int x;
        cin >> x >> t[i];
        p[i] = x;
        pl[t[i]].push_back(x);
    }
    set<PII> q;
    for (int i = 1;  i <= n ;i++) {
        if (pl[i].size() == 0)
            q.insert(PII(2e9, i));
        else {
            q.insert(PII(pl[i][0], i));
        }
    }

    ll ans = 0;
    for (int i = 1; i <= m; i++) {
        int x = p[i] - p[i - 1];
        while (x && !q.empty()) {
            auto [plp, col] = *q.begin();
            // cout << i << " " << plp << " " << col << endl;
            q.erase(q.begin());
            int lft = min(now[col], x);
            now[col] -= lft;
            x -= lft;
            ans += lft;
            if (now[col] != 0) {
                q.insert(PII(plp, col));
            }
        }
        int nowcol = t[i];
        if (q.find(PII(p[i], t[i])) != q.end()) {
            q.erase(q.find(PII(p[i], t[i])));
        }
        tmp[nowcol]++;
        now[nowcol] = a[nowcol];
        
        q.insert(PII(pl[nowcol][tmp[nowcol]], nowcol));
        // cout << "add "  << pl[nowcol][tmp[nowcol]] << " " << nowcol << endl;
    }
    for (int i = 1; i <= n; i++){
        ans += now[i];
    }
    cout << ans << el;
}   
int main() 
{
    ios:: sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int T = 1;
    cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3592kb

input:

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

output:

12
8

result:

wrong answer 2nd lines differ - expected: '9', found: '8'