QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#880984#9528. New Energy VehicleAdamGS#WA 1ms3584kbC++231.2kb2025-02-04 06:40:162025-02-04 06:40:23

Judging History

This is the latest submission verdict.

  • [2025-02-04 06:40:23]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3584kb
  • [2025-02-04 06:40:16]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const ll INF=1e18+7;
void solve() {
    int n, m;
    cin >> n >> m;
    vector<ll>T(n), li(n);
    rep(i, n) cin >> T[i];
    vector<ll>V[n];
    vector<pair<ll,ll>>P;
    rep(i, m) {
        ll x, t;
        cin >> x >> t; --t;
        V[t].pb(x);
        P.pb({x, t});
    }
    rep(i, n) V[i].pb(INF);
    vector<ll>akt=T;
    set<pair<ll,ll>>q;
    rep(i, n) q.insert({V[i][0], i});
    ll l=0, ans=0;
    while(!q.empty()) {
        auto it=q.begin();
        auto a=*it;
        q.erase(it);
        ans+=akt[a.nd];
        akt[a.nd]=0;
        while(l<P.size() && P[l].st<=ans) {
            if(q.find({V[P[l].nd][li[P[l].nd]], P[l].nd})!=q.end()) q.erase({V[P[l].nd][li[P[l].nd]], P[l].nd});
            ++li[P[l].nd];
            akt[P[l].nd]=T[P[l].nd];
            q.insert({V[P[l].nd][li[P[l].nd]], P[l].nd});
            ++l;
        }
    }
    cout << ans << '\n';
}
int main() {
	int _=1;
	cin >> _;
	while(_--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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:

10
12
4
12
999999999
2000000000

result:

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