# Google Code Jam 2013 - Round 1B - Osmos

`Small Input : 4668/7250 users correct (64%)Large Input : 3537/4578 users correct (77%)`
`# include <iostream># include <cstdio># include <algorithm> using namespace std;int Sizes[101];int Total, A, N, Temp, Counter;int getDiff (int A, int B, int & C){    while (A <= B)    {        C++;        A += (A-1);    }    return A;}int Solve (int idx, int CurrentScore, int Changes){    if (idx == N) return Changes;    if (CurrentScore == 1)        return Solve (idx + 1, CurrentScore, Changes + 1);    else if (Sizes[idx] < CurrentScore)        return Solve (idx + 1, CurrentScore + Sizes[idx], Changes);    else    {        int tChanges = 0;        int Diff = getDiff (CurrentScore, Sizes[idx], tChanges) + Sizes[idx];        int Min1 = Solve (idx + 1, Diff, Changes + tChanges);        if (Sizes[idx] > CurrentScore)           return min (Solve (idx + 1, CurrentScore, Changes+1), Min1);        else return Min1;    }}int main(){    //freopen ("Input.txt", "r", stdin);    //freopen ("Scratch.txt", "w", stdout);    scanf ("%d", &Total);    for (int i = 1; i <= Total; i++)    {        scanf ("%d%d", &A, &N);        Temp = A;        Counter = 0;        for (int j = 0; j < N; j++) scanf ("%d", &Sizes[j]);        sort (Sizes, Sizes + N);        printf ("Case #%d: %d\n", i, Solve (0, A, 0));    }}`