QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#737305 | #9528. New Energy Vehicle | wsxcb# | WA | 0ms | 3844kb | C++17 | 1.1kb | 2024-11-12 15:25:27 | 2024-11-12 15:25:28 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void solve() {
int n, m;
cin >> n >> m;
vector<int> a(n + 1);
for (int i = 1 ; i <= n ; i++)
cin >> a[i];
auto tmp = a;
vector<int> x(m + 1), t(m + 1);
for (int i = 1 ; i <= m ; i++)
cin >> x[i] >> t[i];
vector<int> last(m + 1), next(m + 1);
for (int i = m ; i ; i--) {
next[i] = last[t[i]];
last[t[i]] = i;
}
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
for (int i = 1 ; i <= n ; i++) {
q.push({last[i], i});
}
int ans = 0, jishu = 0;
while (q.size()) {
auto [P, id] = q.top();
q.pop();
int cur = x[jishu] - ans;
if (jishu <= m && a[id] >= cur) {
a[id] -= cur, ans += cur, a[jishu] = tmp[jishu];
q.push({next[jishu], t[jishu]});
if (id != t[jishu])
q.push({P, id});
jishu++;
} 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 = 1;
cin >> t;
while (t--)
solve();
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3844kb
input:
2 3 1 3 3 3 8 1 2 2 5 2 1 2 2 1
output:
11 9
result:
wrong answer 1st lines differ - expected: '12', found: '11'