This question already has an answer here:
Captain Jack and his crew have uncovered another treasure full of glistening golds and shiny silvers. There are 2015 chest and each of them contains some amount of gold and silver coins. Different chests may contain different amounts of gold or silver.
Captain Jack, being greedy as ever, wants to keep at least half of the gold and half of the silver. However, he is aware of dissatisfaction among the crew and wants to avoid a mutiny at all costs. So, he wants to give the crew as many treasure chests as possible.
Captain Jack must tell the crews how many chests he is going to give them before he opens up the chests. After that he opens up each chest and decides which chests to keep and which to give away.
What number should Jack tell the crews to ensure that he keeps at least half of the gold and half of the silver while keeping the crew as satisfied as possible? In other words, Find the maximum $N$ such that Jack can always distribute the chests in such a way that he gets to keep half the gold and half the silver and give away $N$ chests.
The captain may count how many silver and gold is in each chest, but cannot remove any gold or silver from its chest, since doing so will result in a irreversible curse for the entire crew and the captain.
Without opening a chest there is no way to tell how many gold or silver it contains.