QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#712363 | #9528. New Energy Vehicle | lanhuo | Compile Error | / | / | C++17 | 1.4kb | 2024-11-05 15:26:40 | 2024-11-05 15:26:41 |
Judging History
This is the latest submission verdict.
- [2024-11-05 15:26:41]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-11-05 15:26:40]
- Submitted
answer
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
#define int long long
#define endl '\n'
#define fi first
#define se second
int n,m,ans;
void solve(){
cin>>n>>m;
ans=0;
vector<int>a(n+1),aa(n+1);
for(int i=1;i<=n;++i){
cin>>a[i];
aa[i]=a[i];
}
vector<int>b(m+1),c(m+1);
for(int i=1;i<=m;++i){
cin>>b[i]>>c[i];
}
vector<int>pos[n+1];
for(int i=1;i<=n;++i){
pos[i].emplace_back(c[m]+1);
}
for(int i=m;i>=1;--i){
pos[c[i]].emplace_back(b[i]);
}
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int>> >qu;
for(int i=1;i<=n;++i){
qu.push({pos[i].back(),i});
pop();
}
for(int i=0;i<m;++i){
int cnt=b[i]-ans;
while(!q.empty()&&cnt){
auto it=q.top();
q.pop();
if(cnt>=a[it.se]){
cnt-=a[it.se];
a[it.se]=0;
}
else{
a[it.se]-=cnt;
cnt=0;
if(it.fi>b[i])qu.push(it)
}
}
if(cnt){//跑不过这个点
cout<<b[i]-cnt<<endl;
return;
}
ans=b[i];
a[c[i]]=aa[c[i]];
if(!pos[c[i]].empty()){
q.push(pos[c[i]].back(),c[i]);
pos[c[i]].pop_back();
}
}
for(int i=1;i<=n;++i){
ans+=a[i];
}
cout<<ans<<endl;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int __=1;
cin>>__;
while(__--)solve();
return 0;
}
Details
answer.code: In function ‘void solve()’: answer.code:34:17: error: ‘pop’ was not declared in this scope; did you mean ‘pos’? 34 | pop(); | ^~~ | pos answer.code:38:24: error: ‘q’ was not declared in this scope 38 | while(!q.empty()&&cnt){ | ^ answer.code:58:25: error: ‘q’ was not declared in this scope 58 | q.push(pos[c[i]].back(),c[i]); | ^