为什么RE了
查看原帖
为什么RE了
800499
suzhikz楼主2023/3/31 13:25
#include<bits/stdc++.h>
using namespace std;
long long a[250005],b[250005];
int n;
bool book[250005]={0};
typedef pair<long long,int> pii;
priority_queue<pii,vector<pii>,less<pii> >q;
long long now;
long long ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)cin>>b[i];
	for(int i=1;i<=n;i++){
		now+=a[i];
		if(now>=b[i]){
			ans++;
			now-=b[i];
			q.push((pii){b[i],i});
			book[i]=1;
		}else if(b[i]<q.top().first&&!q.empty()){
			book[i]=1;
			book[q.top().second]=0;
			now=now+q.top().first-b[i];
			q.pop();
			q.push((pii){b[i],i});
		}
	}
	cout<<ans<<endl;
	for(int i=1;i<=n;i++){
		if(book[i]) printf("%d ",i);
	}
	return 0;
}
2023/3/31 13:25
加载中...