Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.

book
Gifts

You have gifts, and each gift contains a certain number of candies and oranges. Your goal is to make all gifts identical in terms of the number of candies and oranges. You are allowed to perform the following operations on any gift:

  • Remove one candy.
  • Remove one orange.
  • Remove one candy and one orange at the same time.
  • You cannot remove more than what is available in a gift (no negative values).

After performing some moves, all gifts must have the same number of candies and the same number of oranges (though candies and oranges do not need to be equal to each other). Your task is to find the minimum number of moves required to achieve this.

Example 1

Input:

candies = [3, 5, 6]; oranges = [3, 2, 3]

Output:

6
main.cpp

main.cpp

C++

AIに質問する

expand

AIに質問する

ChatGPT

䜕でも質問するか、提案された質問の1぀を詊しおチャットを始めおください

some-alt