All Tracks Algorithms Greedy Algorithms Basics of Greedy Algorithms Problem

Dorsplen
Tag(s):

Algorithms, Easy

Problem
Editorial
Analytics

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.

SAMPLE INPUT
4 5 8
SAMPLE OUTPUT
7
Explanation

Edward has to get two blue gems and then each of the next six turns get one of each red, green and blue gems.

Edward will end with 6 red gems, 6 green gems and 8 blue gems, which is enough to buy the artifact.

Time Limit: 2.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Visual Basic, Kotlin

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

HackerEarth

Challenge Name

February Easy '17

OTHER PROBLEMS OF THIS CHALLENGE
Notifications
View All Notifications