# |
Author |
Problem |
Lang |
Verdict |
Time |
Memory |
Sent |
Judged |
|
21623570 |
Practice:
bluefi |
727F
- 27
|
GNU C++11
|
Accepted
|
1169 ms
|
16 KB
|
2016-10-20 19:54:17 |
2016-10-20 19:54:18 |
|
#include <bits/stdc++.h>
using namespace std;
const int N= 755;
#define ll long long
ll dp[N],mini= -1e18,u;
int a[N];
int main(){
int n,m,i,j;
cin>>n>>m;
for(i=1;i<=n;++i)scanf("%d",&a[i]),dp[i]= mini;
for(i=n;i>=1;--i){
for(j=n;j>=0;--j){
if(j==0)u= mini;else u = dp[j-1];
dp[j]= max( min(dp[j]+a[i],0LL),u);
}
}
while(m--){
cin>>u;
j= lower_bound(dp,dp+n+1,-u)-dp;
printf("%d\n",j);
}
}
Click to see test details