QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#696602 | #9528. New Energy Vehicle | panelope | WA | 1ms | 5580kb | C++20 | 1.5kb | 2024-10-31 23:45:24 | 2024-10-31 23:45:26 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n,m;
struct ty{
long long x,t,cur;
int i;
bool operator > (const ty &b) const{
return t > b.t;
}
};
ty a[100010];
long long x[100010],t[100010];
int main(){
int T;
cin >> T;
while(T--){
cin >> n >> m;
long long ans = 0;
for(int i=1; i<=n; i++)
{
cin >> a[i].x;
a[i].cur = a[i].x;
a[i].i = i;
ans += a[i].x;
}
priority_queue<ty,vector<ty>,greater<ty>> q;
for(int i=1; i<=m; i++)
{
cin >> x[i] >> t[i];
a[t[i]].t = x[i];
q.push(a[i]);
}
for(int i=1; i<=n; i++)
if(a[i].t == 0)
a[i].t = 1e9+1;
for(int i=1; i<=m; i++){
long long p = 0;
while(p < x[i]-x[i-1] && !q.empty()){
ty cur = q.top();
q.pop();
long long l = x[i]-x[i-1] - p;
if(cur.cur>=l){
a[cur.i].cur -= l;
p += l;
}
else{
p += cur.cur;
a[cur.i].cur = 0;
}
//cout << cur.i <<' ' <<a[cur.i].cur << endl;
}
if(p!=x[i]-x[i-1])break;
ans += a[t[i]].x - a[t[i]].cur;
a[t[i]].cur = a[t[i]].x;
a[t[i]].t = 1e9+1;
q.push(a[t[i]]);
}
cout << ans << endl;
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5580kb
input:
2 3 1 3 3 3 8 1 2 2 5 2 1 2 2 1
output:
9 9
result:
wrong answer 1st lines differ - expected: '12', found: '9'