General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
40910884 Practice:
world_top_1_AD_uzi
727F - 27 C++17 (GCC 7-32) Accepted 124 ms 24 KB 2018-07-29 11:45:34 2018-07-29 11:45:34
→ Source
#include<bits/stdc++.h>
using namespace std;

int n, m;
long long u;
long long a[1000], d[1000];
long long ans = -1e17;
int main(){
	int i, j;
	scanf("%d %d", &n, &m);
	for (i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
		d[i] = -1e17;
	}
	for (i = n; i >= 0; i--)
		for (j = n; j >= 0; j--) {
			u = (j == 0) ? ans : d[j - 1];
			d[j] = max(min(d[j] + a[i], (long long)0), u);
		}
	while (m--) {
		scanf("%lld", &u);
		printf("%d\n", lower_bound(d, d + n + 1, -u) - d);
	}
	return 0;
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details