记录编号 | 382842 | 评测结果 | AAAAAAAAAA | ||
---|---|---|---|---|---|
题目名称 | 烤鸡翅 | 最终得分 | 100 | ||
用户昵称 | 是否通过 | 通过 | |||
代码语言 | C++ | 运行时间 | 0.938 s | ||
提交时间 | 2017-03-14 19:33:18 | 内存使用 | 4.13 MiB | ||
#include<iostream> #include<cstdio> #include<queue> #define maxn 250001 #define ll long long using namespace std; ll n,now=0,ans=0,ans_=0,q_top; ll a[maxn],b[maxn]; priority_queue<int> q; void input(){ cin>>n; for(int i=0;i<n;i++) cin>>a[i]; for(int i=0;i<n;i++) cin>>b[i]; } void work(){ for(int i=0;i<n;i++){ now+=a[i]; now-=b[i]; ans++; q.push(b[i]); if(now<0){ if(!q.empty()) q_top=q.top(),now+=q_top,q.pop(),ans--; } ans_=max(ans,ans_); } cout<<ans_; } int main(){ freopen("wing.in","r",stdin); freopen("wing.out","w",stdout); input(); work(); return 0; }