QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#696584 | #9528. New Energy Vehicle | panelope | WA | 1ms | 5644kb | C++20 | 1.6kb | 2024-10-31 23:38:39 | 2024-10-31 23:38:39 |
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;
}
for(int i=1; i<=m; i++)
{
cin >> x[i] >> t[i];
a[t[i]].t = x[i];
}
for(int i=1; i<=n; i++)
if(a[i].t == 0)
a[i].t = 1e9+1;
priority_queue<ty,vector<ty>,greater<ty>> q;
for(int i=1; i<=n; i++){
q.push(a[i]);
}
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;
}
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;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5644kb
input:
2 3 1 3 3 3 8 1 2 2 5 2 1 2 2 1
output:
1 0 2 0 3 1 12 2 1 1 4 9
result:
wrong answer 1st lines differ - expected: '12', found: '1 0'