Google Code Jam 2013 - Round 1B - Osmos
Table of Contents
Today, I would like to share my solution to the Google Code Jam 2013's Round 1B's Osmos problem. These are the statistics for that problem\\
I believe it was tricky enough for an easy problem. Many people have got atleast one wrong try. Here is how I solved it (I couldn't solve it during the contest).
\\
1# include <iostream>
2# include <cstdio>
3# include <algorithm>
4
5using namespace std;
6int Sizes[101];
7int Total, A, N, Temp, Counter;
8int getDiff (int A, int B, int & C)
9{
10 while (A CurrentScore)
11 return min (Solve (idx + 1, CurrentScore, Changes+1), Min1);
12 else return Min1;
13 }
14}
15int main()
16{
17 //freopen ("Input.txt", "r", stdin);
18 //freopen ("Scratch.txt", "w", stdout);
19 scanf ("%d", &Total);
20 for (int i = 1; i <= Total; i++)
21 {
22 scanf ("%d%d", &A, &N);
23 Temp = A;
24 Counter = 0;
25 for (int j = 0; j < N; j++) scanf ("%d", &Sizes[j]);
26 sort (Sizes, Sizes + N);
27 printf ("Case #%d: %d\n", i, Solve (0, A, 0));
28 }
29}Here is the ideone URL http://ideone.com/g5qxYd where I tested the program with Google's inputs.