QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#697918 | #9528. New Energy Vehicle | czrq# | Compile Error | / | / | C++17 | 1.5kb | 2024-11-01 16:23:39 | 2024-11-01 16:23:42 |
Judging History
This is the latest submission verdict.
- [2024-11-01 16:23:42]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-11-01 16:23:39]
- Submitted
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M=1e5+5;
ll id[M],a[M],n,m,k;
ll b[M];
ll nex[M];
bool vis[M];
struct node {
ll x,t;
bool operator<(const node ss) const {
return x>ss.x;
}
} no[M];
void solve() {
cin>>n>>m;
priority_queue<node> q;
for(int i=1; i<=n; i++) {
cin>>a[i];
b[i]=a[i];
vis[i]=0;
nex[i]=0;
id[i]=0;
}
for(int i=1; i<=m; i++) {
cin>>no[i].x>>no[i].t;
vis[no[i].t]=1;
q.push(no[i]);
}
long long an=0;
for(int i=1; i<=n; i++) {
if(vis[i]==0) {
an+=a[i];
}
}
for(int i=m; i>=1; i--) {
if(id[no[i].t]) nex[i]=id[no[i].t];
id[no[i].t]=i;
}
int flag=0;
long long sum=0;
no[0].x=0;
no[0].t=0;
nex[0]=0;
a[0]=0;
for(int i=0; i<m; i++) {
if(i>=1) {
if(nex[i]) {
q.push(no[nex[i]]);
b[no[i].t]=a[no[i].t];
}
else {
an+=a[no[i].t];
}
}
while(q.size()&&(no[i].x>=q.top().x)q.pop();
long long res=no[i+1].x-no[i].x;
while(res) {
if(!q.size()) {
an-=res;
res=0;
if(an<0) {
flag=1;
}
break;
}
ll v=q.top().t;
ll ans=min(res,b[v]);
res-=ans;
b[v]-=ans;
if(b[v]==0) {
q.pop();
}
}
if(flag) {
sum=no[i+1].x+an;
// cout<<i<<"#"<<an<<endl;
break;
}
}
if(!flag) {
sum=(no[m].x+an+a[no[m].t]);
}
cout<<sum<<endl;
}
int main() {
int t;
cin>>t;
while(t--) {
solve();
}
}
詳細信息
answer.code: In function ‘void solve()’: answer.code:60:53: error: expected ‘)’ before ‘q’ 60 | while(q.size()&&(no[i].x>=q.top().x)q.pop(); | ~ ^ | )