QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#686316 | #9528. New Energy Vehicle | crazymoon | WA | 0ms | 3548kb | C++20 | 2.7kb | 2024-10-29 11:09:33 | 2024-10-29 11:09:34 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
const double eps = 1e-8;
void solve() {
int n, m, res = 0;
cin >> n >> m;
vector<int> a(n + 1), ta(n + 1), lst(n + 1);
vector<pair<int, int>> b(m + 1);
for (int i = 1; i <= n; ++i) {
cin >> a[i];
ta[i] = a[i];
}
for (int i = 1; i <= m; ++i) cin >> b[i].first >> b[i].second;
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q1, q2;
priority_queue<array<int, 3>, vector<array<int, 3>>, greater<array<int, 3>>> q3;
for (int i = 1; i <= m; ++i) q1.push(b[i]);
for (int i = 1; i <= n; ++i) q1.push({1e15, i});
for (int i = 0; q1.size() != 0 ; res = i) {
auto t1 = q1.top();
q1.pop();
if(ta[t1.second] == 0) q3.push({lst[t1.second], t1.first, t1.second});
else {
if(res == 31) {
int p = 1;
}
q2.push(t1);
int ti = i + ta[t1.second];
ta[t1.second] = 0;
while(q2.size()) {
auto t2 = q2.top();
if(ti < t2.first) break;
if(q3.size()) {
auto t3 = q3.top();
if(t2.first == t3[0]) {
q3.pop();
q2.pop();
q1.push({t3[1], t3[2]});
ta[t1.second] = ti - t2.first;
ta[t3[2]] = a[t3[2]];
ti = t2.first;
if(ta[t1.second] && t1.second != t3[2]) q1.push(t1);
break;
}
else {
ta[t2.second] = a[t2.second];
if(t1 == t2) ti = t1.first;
}
}
else {
ta[t2.second] = a[t2.second];
}
q2.pop();
}
i = ti;
}
lst[t1.second] = t1.first;
}
// for (int i = 1; i <= n; ++i) res += ta[i];
// while(q2.size()) {
// auto t2 = q2.top();
// if(res < t2.first) break;
// q2.pop();
// if(q3.size()) {
// auto t3 = q3.top();
// if(t2.first == t3[0]) {
// q3.pop();
// res += t3[2];
// ta[t3[1]] = a[t3[1]] - t3[2];
// }
// else res += a[t2.second];
// }
// else res += a[t2.second];
// }
cout << res << '\n';
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int t = 1; cin >> t;
while(t--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3548kb
input:
2 3 1 3 3 3 8 1 2 2 5 2 1 2 2 1
output:
12 14
result:
wrong answer 2nd lines differ - expected: '9', found: '14'