General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
22015700 Practice:
aufeas
727F - 27 GNU C++ Accepted 171 ms 4820 KB 2016-11-03 17:54:18 2016-11-03 17:54:46
→ Source
#include <algorithm>
#include <cstring>
#include <cstdio>
int a[800],n,m;
long long f[800][800];
int main(){
	scanf("%d%d\n",&n,&m);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	memset(f,127,sizeof f);
	f[n+1][0]=0;
	for (int i=n;i;i--)
		for (int j=0;j<=n-i+1;j++){
			f[i][j]=f[i+1][j];
			if (j) f[i][j]=std::min(f[i][j],std::max(f[i+1][j-1]-a[i],0ll));
		}
	for (int i=1;i<=m;i++){
		long long x;
		scanf("%I64d\n",&x);
		printf("%d\n",n-(std::upper_bound(f[1],f[1]+n+1,x)-f[1]-1));
	}
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details