记录编号 | 250639 | 评测结果 | AAAAAAAAAA | ||
---|---|---|---|---|---|
题目名称 | 烤鸡翅 | 最终得分 | 100 | ||
用户昵称 | 是否通过 | 通过 | |||
代码语言 | C++ | 运行时间 | 0.274 s | ||
提交时间 | 2016-04-15 16:42:10 | 内存使用 | 2.22 MiB | ||
#include<cstdio> #include<iostream> #include<queue> using namespace std; const int SIZEN=250010,INF=0x7fffffff/2; typedef long long LL; int N,M; int A[SIZEN]; int B[SIZEN]; LL now=0; void read() { scanf("%d",&N); for(int i=1;i<=N;i++) { scanf("%d",&A[i]); } for(int i=1;i<=N;i++) { scanf("%d",&B[i]); } } priority_queue<int> Q; void work() { int ans=0; for(int i=1;i<=N;i++) { now+=A[i]; if(now>=B[i]) { Q.push(B[i]); now-=B[i]; ans++; } else if(!Q.empty()) { int tem=Q.top();Q.pop(); if(tem>B[i]) now+=(LL)tem-B[i],tem=B[i]; Q.push(tem); } } printf("%d\n",ans); } int main() { freopen("wing.in","r",stdin); freopen("wing.out","w",stdout); read(); work(); return 0; }