QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#880981 | #9528. New Energy Vehicle | AdamGS# | RE | 0ms | 0kb | C++23 | 1.1kb | 2025-02-04 06:37:15 | 2025-02-04 06:37:16 |
Judging History
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({t, x});
}
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) {
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();
}
詳細信息
Test #1:
score: 0
Runtime Error
input:
2 3 1 3 3 3 8 1 2 2 5 2 1 2 2 1