| 记录编号 | 
        319113 | 
        评测结果 | 
        AAAAAAAAAA | 
    
    
        | 题目名称 | 
        2235.烤鸡翅 | 
        最终得分 | 
        100 | 
            
    
    
        | 用户昵称 | 
         Rapiz | 
        是否通过 | 
        通过 | 
    
    
        | 代码语言 | 
        C++ | 
        运行时间 | 
        0.200 s  | 
    
    
        | 提交时间 | 
        2016-10-10 13:41:25 | 
        内存使用 | 
        2.41 MiB  | 
        
    
    
    
    		显示代码纯文本
		
		#include<cstdio>
#include<algorithm>
#include<queue> 
using std::swap;
#define file(x) "wing."#x
typedef long long ll;
const int MAXN=250010;
int n,ans;
ll x[MAXN],y[MAXN],st[MAXN],sz;
std::priority_queue<ll> q;
void up(int o){
	while(o>1&&st[o]>st[o>>1]) swap(st[o],st[o>>1]),o>>=1;
}
void down(int o){
	while((o<<1)<=sz){
		int mxch=o<<1;
		if(mxch+1<=sz&&st[mxch+1]>st[mxch]) mxch++;
		if(st[mxch]>st[o]) swap(st[mxch],st[o]),o=mxch;
		else break;
	}
}
void in(int x){
	st[++sz]=x;
	up(sz);
}
void pop(){
	swap(st[sz],st[1]);
	sz--;
	down(1);
}
int Main(){
	freopen(file(in),"r",stdin);
	freopen(file(out),"w",stdout);
	scanf("%d",&n);
	int t;
	for(int i=1;i<=n;i++) scanf("%d",&t),x[i]=t;
	for(int i=1;i<=n;i++) scanf("%d",&t),y[i]=t;
	ll lft=0;
	for(int i=1;i<=n;i++){
		lft+=x[i];
		if(lft>=y[i]) in(y[i]),lft-=y[i],ans++;
		else{
			if(sz){
				int top=st[1];
				if(y[i]<top) pop(),lft+=top,lft-=y[i],in(y[i]);
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}
int enter=Main();
int main(){
}