QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#722678 | #9528. New Energy Vehicle | xixixi | WA | 24ms | 9992kb | C++14 | 1.9kb | 2024-11-07 19:54:48 | 2024-11-07 19:54:50 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mxn=1e5+7,mxm=5e5+7;;
int n,m,a[mxn],x[mxn],t[mxn],c[mxn];
int T,vis[mxn];
struct ST{
int dis,id;
bool operator<(const ST& other)const{
// if(c[id]==0) return true;
if(c[other.id]==0) return false;
// if(c[id]==0&&c[other.id]>0)return true;
return dis>other.dis;
}
};
signed main(){
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin>>T;
while(T--){
priority_queue<ST> q;
cin>>n>>m;
for(int i=1;i<=n;i++) cin>>a[i],c[i]=a[i],vis[i]=0;
for(int i=1;i<=m;i++){
cin>>x[i]>>t[i];
q.push({x[i],t[i]});
vis[t[i]]+=1;
}
// cout<<q.top().dis<<'\n';
int tmp=0;
for(int i=1;i<=n;i++) if(!vis[i]) tmp+=a[i];
// cout<<tmp<<' ';
int now=0,ans=0,fg=1;
while(!q.empty()){
int to=q.top().dis;
int y=q.top().id;
while(now<to){
while(q.top().dis<=now) q.pop();
int x=q.top().id;
int px=q.top().dis;
if(c[x]==0){
int dx=min(tmp,to-now);
now+=dx;
tmp-=dx;
break;
}
int dx=min(to-now,c[x]);
c[x]-=dx;
if(c[x]==0)
q.pop(),
q.push({px,x});
// if(c[x]==0) in[x]=0;
now+=dx;
}
if(now<to)break;
c[y]=a[y];
while(!q.empty() && q.top().dis<=now)q.pop();
vis[y]--;
if(vis[y]==0) tmp+=c[y];
while(!q.empty() && q.top().dis<=now)q.pop();
}
// cout<<now<<' '<<tmp<<' ';
now+=tmp;
cout<<now<<'\n';
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5604kb
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: 0
Accepted
time: 1ms
memory: 5880kb
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:
9 11 4 11 999999999 2000000000
result:
ok 6 lines
Test #3:
score: -100
Wrong Answer
time: 24ms
memory: 9992kb
input:
10 230 8042 599 1039 69 1011 1366 824 14117 1523 806 5002 332 55 3769 996 359 1040 255 1135 3454 3609 6358 2509 3695 8785 3890 1304 3394 14611 33 89 2245 508 22 1043 10411 628 1279 714 903 585 7413 5099 845 148 4689 2110 8683 1613 143 3263 2599 110 244 3297 4742 1571 425 1822 15692 572 9397 328 1691...
output:
130676 574958 336627 377179 244234 10860 361980 294680 245645 260009
result:
wrong answer 1st lines differ - expected: '1543020', found: '130676'