记录编号 | 447680 | 评测结果 | AAAAAAAAAA | ||
---|---|---|---|---|---|
题目名称 | 烤鸡翅 | 最终得分 | 100 | ||
用户昵称 | 是否通过 | 通过 | |||
代码语言 | C++ | 运行时间 | 0.266 s | ||
提交时间 | 2017-09-11 10:24:13 | 内存使用 | 4.13 MiB | ||
#include<bits/stdc++.h> #define ll long long using namespace std; ll n,x[250005],y[250005],now,cnt; priority_queue<int>S; int main() { freopen("wing.in","r",stdin); freopen("wing.out","w",stdout); scanf("%lld",&n); for(int i=1;i<=n;i++)scanf("%lld",&x[i]); for(int i=1;i<=n;i++)scanf("%lld",&y[i]); for(int i=1;i<=n;i++){ now+=x[i]; if(now>=y[i]){ now-=y[i]; S.push(y[i]); } else { cnt++; if(!S.empty()){ int u=S.top(); if(u>y[i]){ now+=u; S.pop(); now-=y[i]; S.push(y[i]); } } } } cout<<n-cnt; return 0; }