Question Name:DORSPLEN

#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    long long count=(a[2]-a[1]);
    count=ceil((long double)count/(long double)2);
    count+=a[1];
    cout<<count;
}
  • Problem Description
    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 <= r,g,b <=10^18

    Output format

    Output single integer: the minimum number of turns Edward has to make to be able to buy the artifact.
  • Test Case 1
    Input (stdin)4 5 8
    Expected Output7
  • Test Case 2
    Input (stdin)57 54 100
    Expected Output79

vizer apk

share me app

Leave a Reply

Your email address will not be published. Required fields are marked *

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
CHP Adblock Detector Plugin | Codehelppro