I am trying out this problem on Codeforces. https://codeforces.com/contest/478/problem/C
I get the correct output for the test case 5 4 3 as 4 in my system, which is also the output of the sample test case.
Here is my code. Could someone please tell where I am going wrong ?
But the online judge shows my answer as 3 and hence failed in the first test case.
1 Time: 15 ms, memory: 0 KB Verdict: WRONG_ANSWER Input
5 4 3
Participant's output
3
Jury's answer
4
Checker comment
wrong answer 1st numbers differ — expected: '4', found: '3'
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
int r,g,b;
cin>>r>>g>>b;
int mini=min(min(r,g),b);
int ans=mini;
int maxi=max(max(r,g),b);
int sma;
if(r!=maxi && r!=mini)
r=sma;
else if(g!=maxi && g!=mini)
g=sma;
else
b=sma;
if(maxi > 2*sma)
{
ans+=sma;
}
else
{
ans+=((sma+maxi)/3);
}
cout<<ans<<endl;
return 0;
}
I think here where the arrow points is wrong . It's should be
sma = r ...