QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#715045 | #9528. New Energy Vehicle | ucup-team4717# | WA | 2ms | 10224kb | C++20 | 1.7kb | 2024-11-06 10:06:00 | 2024-11-06 10:06:03 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define fi first
#define sd second
using namespace std;
const int N=5e5+5,inf=1e18;
inline int read(){
int x;
scanf("%lld",&x);
return x;
}
int T,n,m,a[N],x[N],t[N],b[N];
bool vis[N];
/*
1
2 2
5 2
1 2
2 1
*/
signed main(){
T=read();
while(T--){
n=read(),m=read();
for(int i=1;i<=n;i++) b[i]=a[i]=read();
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > q,qq;
for(int i=1;i<=m;i++){
x[i]=read(),t[i]=read();
vis[t[i]]=1;
q.push({x[i],t[i]});
qq.push({x[i],t[i]});
}
for(int i=1;i<=n;i++) if(!vis[i]) q.push({inf,i}),qq.push({inf,i});
qq.push({inf,1});
int pos=0;
// cerr<<1;
while(!qq.empty()){
// cerr<<2;
int x=qq.top().fi,id=qq.top().sd;
qq.pop();
// cout<<"S:"<<x<<" "<<id<<"\n";
while(!q.empty()){
// cerr<<3;
int X=q.top().fi,ID=q.top().sd;
q.pop();
if(a[ID]<=x-pos){
pos+=a[ID];
// cout<<"us1:"<<ID<<"\n";
}
else{
// cout<<"us2:"<<ID<<"\n";
a[ID]-=(x-pos),pos=x;
if(id!=ID) q.push({X,ID});
break;
}
}
if(pos<x) break;
a[id]=b[id];
qq.push({inf,id});
q.push({inf,id});
}
printf("%lld\n",pos);
for(int i=1;i<=n;i++) vis[i]=0;
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 9996kb
input:
2 3 1 3 3 3 8 1 2 2 5 2 1 2 2 1
output:
12 9
result:
ok 2 lines
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 10224kb
input:
6 3 2 2 2 2 6 1 7 1 2 2 3 3 2 1 6 2 2 3 2 2 5 1 7 2 9 1 2 2 3 3 2 1 6 2 1 1 999999999 1000000000 1 1 1 1000000000 1000000000 1
output:
11 11 11 11 999999999 2000000000
result:
wrong answer 1st lines differ - expected: '9', found: '11'