Description
A little bear Limak plays a game. He has five cards. There is one number written on each card. Each number is a positive integer.
Limak can discard (throw out) some cards. His goal is to minimize the sum of numbers written on remaining (not discarded) cards.
He is allowed to at most once discard two or three cards with the same number. Of course, he won't discard cards if it's impossible to choose two or three cards with the same number.
Given five numbers written on cards, cay you find the minimum sum of numbers on remaining cards?
Input
The only line of the input contains five integers t1, t2, t3, t4 and t5 (1 ≤ ti ≤ 100) — numbers written on cards.
Output
Print the minimum possible sum of numbers written on remaining cards.
Sample Input
7 3 7 3 20
26
7 9 3 1 8
28
10 10 10 10 10
20
</pre><pre name="code" class="cpp">
</pre><pre name="code" class="cpp">#include<iostream>
using namespace std;
int main()
{
int a[6],flag[2]={1,1},same[2]={0,0},k,i,j,sum=0;
for(i=0;i<5;i++)
{
cin>>a[i];
sum+=a[i];
}
for(i=0,k=0;i<5;i++)
{
if(flag[k]>1) k++;
for(j=i+1;j<5;j++)
{
if(a[j]==a[i]&&a[i]!=0)
{
flag[k]++;
same[k]=a[i];
a[j]=0;
}
}
}
if(flag[0]>3) flag[0]=3;
sum-=flag[0]*same[0]>flag[1]*same[1]?flag[0]*same[0]:flag[1]*same[1];
cout<<sum<<endl;
return 0;
}