QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#880978 | #9528. New Energy Vehicle | AdamGS# | WA | 1ms | 3584kb | C++23 | 1.1kb | 2025-02-04 06:34:34 | 2025-02-04 06:34:36 |
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({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) {
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: 100
Accepted
time: 1ms
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: 0ms
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'