QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#722781 | #9528. New Energy Vehicle | reverSilly | WA | 0ms | 7704kb | C++23 | 1.2kb | 2024-11-07 20:11:10 | 2024-11-07 20:11:15 |
Judging History
answer
// CCPC 2024 Harbin Site J New Energy Vehicle
// https://contest.ucup.ac/contest/1817/problem/9528?v=1
#include<bits/stdc++.h>
using namespace std;
using i64=long long;
constexpr int mxn{200005};
int T,n,m,a[mxn],nx[mxn],cura[mxn],last[mxn];
struct{i64 x;int t;}xt[mxn];
int main()
{
cin.tie(nullptr);
ios::sync_with_stdio(false);
cin>>T;
while(T--)
{
cin>>n>>m;
for(int i=0;i<n;++i)
cin>>a[i];
copy_n(a,n,cura);
for(int i=0;i<m;++i)
{
cin>>xt[i].x>>xt[i].t;
--xt[i].t;
}
xt[m].x=1e18;
fill_n(last,n,1e18);
for(int i=m-1;i>=0;--i)
{
nx[i]=last[xt[i].t];
last[xt[i].t]=xt[i].x;
}
priority_queue<array<int,2>>Q;
for(int i=0;i<n;++i)
Q.push({-last[i],i});
i64 ans=0,i=0;
while(!Q.empty())
{
if(ans==xt[i].x)
{
if(Q.top()[1]==xt[i].t)
Q.pop();
cura[xt[i].t]=a[xt[i].t];
if(nx[i]<1e18)
Q.push({-nx[i],xt[i].t});
++i;
}
auto[_,u]=Q.top();
// cerr<<u<<' '<<ans<<'\n';
i64 dist=min((i64)cura[u],xt[i].x-ans);
cura[u]-=dist;
ans+=dist;
if(cura[u]==0)
Q.pop();
}
cerr<<ans<<'\n';
}
return 0;
}
// 1
// 3 1
// 3 3 3
// 8 1
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 7704kb
input:
2 3 1 3 3 3 8 1 2 2 5 2 1 2 2 1
output:
result:
wrong answer 1st lines differ - expected: '12', found: ''