QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#690448 | #9528. New Energy Vehicle | wzdxhxx | Compile Error | / | / | C++20 | 1.3kb | 2024-10-30 22:14:07 | 2024-10-30 22:14:08 |
Judging History
This is the latest submission verdict.
- [2024-10-30 22:14:08]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-10-30 22:14:07]
- Submitted
answer
#include<bits/stdc++.h>
using namespace std;
#define PII pair<int,int>
#define int long long
void solve() {
int n,m;
cin >> n >> m;
vector<int> a(n + 1) , x(m + 1) , t(m + 1);
for(int i = 1 ; i <= n ; i ++) cin >> a[i];
auto b = a;
priority_queue<PII,vector<PII>,greater<PII>> q;
for(int i = 1 ;i <= m ; i ++) cin >> x[i] >> t[i];
vector<int> nxt(m + 1),mp(n + 1,m + 1);
for(int i = m ; i >= 1 ; i --) { //逆序get电池i的下一个充电站
nxt[i] = mp[t[i]];
mp[t[i]] = i;
}
for(int i = 1 ; i <= n ; i ++) q.emplace(mp[i],i);
int ans = 0 , k = 1;
while(!q.empty())
{
auto [pos,id] = q.top();
q.pop();
int dis;
if(k <= m && a[id] >= (dis = x[k] - ans)) {
a[id] -= dis;
ans += dis;
a[t[k]] = b[t[k]];
q.emplace(nxt[k],t[k]);
if(id != t[k]) q.emplace(pos,id);
++ k;
} else {
ans += a[id];
a[id] = 0;
}
}
cout << ans << "\n";
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
Details
answer.code: In function ‘int main()’: answer.code:49:12: error: ‘t--’ was not declared in this scope 49 | while (t--) { | ^~~~~