In this **HackerEarth Dorsplen problem solution,** 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.

## HackerEarth Dorsplen problem solution.

#include <cstdio>
#include <algorithm>
#include <cassert>
int main() {
long long a, b, c;
assert(scanf("%lld%lld%lld", &a, &b, &c) == 3);
long long t = std::min(std::min(a, b), c);
a -= t;
b -= t;
c -= t;
printf("%lld\n", (a + b + c + 1) / 2 + t);
}

### Second solution

#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <assert.h>
#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define eps 1e-8
#define M_PI 3.141592653589793
#define bs 1000000007
#define bsize 512
#define ldouble long double
using namespace std;
long long INF = 1e9;
const int N = 210031;
long long r,g,b;
long long ans;
int main(){
ios_base::sync_with_stdio(0);
cin>>r>>g>>b;
ans=min(r,min(g,b));
r-=ans;
g-=ans;
b-=ans;
ans+=(r+g+b)/2+(r+g+b)%2;
cout<<ans<<endl;
cin.get(); cin.get();
return 0;
}

Thursday, January 13, 2022