样例输出
3
1 2 4
我的输出
3
1 2 3
我的代码
#include<bits/stdc++.h>
#define zhujvnhan return
#define AK 0
#define CSP ;
using namespace std;
typedef pair<long long,int> ll;
long long a[300005];
long long b[300005];
bool f[300005];
priority_queue<ll,vector<ll>,less<ll> > q;
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++)cin>>a[i];
for(int i=1;i<=n;i++)cin>>b[i];
long long tot=0,cnt=0;
for(int i=1;i<=n;i++){
tot+=a[i];
if(tot<b[i]&&!q.empty()&&q.top().first>b[i]){
f[q.top().second]=false;
tot+=q.top().first;
q.pop();
cnt--;
}
if(tot>=b[i]){
tot-=b[i];
q.push((ll) {b[i],i});
f[i]=true;
cnt++;
}
}
printf("%lld\n",cnt);
for(int i=1;i<=n;i++){
if(f[i])cout<<i<<' ';
}
zhujvnhan AK CSP;
}