summaryrefslogtreecommitdiff
path: root/11264/coin.c
blob: 2fa2dbb55fe3f2d2e059f9caa455de1186c67209 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <stdio.h>
#include <stdlib.h>

int greedy(int c[], int size)
{
    int k = 0, curr_sum = c[0];
    int types = 2, x;
    for (x=1; x < size-1; x++) {
	if (c[x] + curr_sum < c[x+1]) {
	    curr_sum += c[x];
	    types++;
	}
    }
    return types;
}

int main()
{
    int tc;
    scanf("%d", &tc);

    while (tc--) {	
	int n, c[1000], x;
	scanf("%d", &n);
	for (x=0; x<n; x++) {
	    int k;
	    scanf("%d", &k);
	    c[x] = k;
	}
	int types = greedy(c, n);
	
	printf("%d\n", types);
    }
}