1 条题解
-
1
#include<bits/stdc++.h> using namespace std; void read(long long &h){ char o; long long x=0,y=1; o=getchar_unlocked(); while(!(o<='9'&&o>='0')){ if(o=='-'){ y=-1; } o=getchar_unlocked(); } while(o<='9'&&o>='0'){ x*=10; x+=o-'0'; o=getchar_unlocked(); } h=x*y; return ; } priority_queue<long long,deque<int>,greater<int>> a; long long cmp,now,sum; long long n,p; int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); read(n);read(p); for(int i=1;i<=n;i++){ read(cmp); a.push(cmp); sum+=cmp; while(a.size()&&sum-a.top()>=p){ sum-=a.top(); a.pop(); } if(sum<p){ cout<<-1; } else{ cout<<a.size(); } cout<<" "; } return 0; }
- 1
信息
- ID
- 38693
- 时间
- 2000ms
- 内存
- 1024MiB
- 难度
- 5
- 标签
- 递交数
- 1
- 已通过
- 1
- 上传者