Dorsplen
Practice
2.7 (15 votes)
Algorithms
Approved
Easy
Greedy algorithms
Problem
92% Success 7838 Attempts 20 Points 2s Time Limit 256MB Memory 1024 KB Max Code

Edward is playing a simplified version of game called "Dorsplen". This game is played with gems of three different colors: red, green and blue. Initially player has no gem and there are infinitely many gems of each color on the table.

On each turn a player can either acquire gems or buy an artifact. Artifact can be bought using gems. On acquiring gems player can get three gems of distinct colors or two gems of the same color from the table.

Edward is planning to buy an artifact, it costs r red gems, g green gems and b blue gems. Compute, what is the minimum number of turns Edward has to make to earn at least r red gems, g green gems and b blue gems, so that he will be able to buy the artifact.

Input format

Input contains three integers in a single line r, g and b — the number of red, green and blue gems, respectively, required to buy the artifact.

Constraints

\(0 \le r, g, b \le 10^{18}\)

Output format

Output single integer: the minimum number of turns Edward has to make to be able to buy the artifact.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
36 votes
Tags:
Greedy algorithmAlgorithmsBasics of Greedy AlgorithmsGreedy Algorithms
Points:20
7 votes
Tags:
Greedy AlgorithmsAlgorithmsBasics of Greedy AlgorithmsGreedy algorithm
Points:20
28 votes
Tags:
AlgorithmsEasyGreedy Algorithms