I ve been searching for various algorithms for the past few days and I came accross this one.
Is this the right solution to it (Greedy algorithm), or am i missing something.
static void Main(string[] args)
{
int[] array = new int[71]{
72, 79, 84, 46, 14, 4, 62, 88, 58, 21, 16, 27, 13, 52, 96, 70, 28, 75,
76, 45, 5, 71, 43, 87, 64, 95, 72, 22, 43, 15, 25, 70, 64, 93, 56, 90,
84, 31, 49, 71, 29, 46, 6, 17, 81, 21, 75, 44, 2, 45, 67, 57, 93, 72,
39, 74, 43, 53, 40, 45, 87, 23, 44, 52, 1, 56, 32, 26, 32, 67, 41};
Array.Sort(array);
List<int> lista = array.ToList();
List<int> A = new List<int>();
List<int> B = new List<int>();
A.Add(lista[0]);
B.Add(lista[1]);
for (int i = 0; i <lista.Count; i++)
{
if (A.Sum() > B.Sum())
{
B.Add(i);
}
else
{
A.Add(i);
}
}
Console.WriteLine(A.Sum());
Console.WriteLine(B.Sum());
Console.ReadLine();
}