예제 #1
0
    public static void PopAll(MyStack[] stacks)
    {
        if (!stacks.Any() || stacks.Length == 1) return;

        while (true)
        {
            for (var i = 0; i < stacks.Length; i++)
            {
                var curStack = stacks[i];
                if (stacks.Where((v, _i) => _i != i && curStack.Sum > v.Sum).Any())
                {
                    curStack.Pop();
                }
            }

            if (stacks.All(_ => _.Sum == stacks.First().Sum)) break;
        }
    }