Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <cstring>
- #include<iostream>
- #include<cmath>
- #include<algorithm>
- #include<map>
- #include<vector>
- #include<set>
- using namespace std;
- int main()
- {
- int ar[6];//,b,c,d,e;
- std::map<int,int>m;
- std::set<int>s;
- std::set<int>::iterator it;
- int sum=0;
- for(int i=0;i<5;i++)
- {
- cin>>ar[i];
- s.insert(ar[i]);
- m[ar[i]]++;
- sum+=ar[i];
- }
- if(s.size()==1)
- {
- cout<<ar[0]*2<<endl;
- return 0;
- }
- else if(s.size()==5)
- {
- cout<<sum<<endl;
- return 0;
- }
- else if(s.size()==2)
- {
- it=s.begin();
- int temp1=*it;
- it++;
- int temp2=*it;
- int zsum=0,tsum=0;
- tsum+=temp1*m[temp1];
- zsum+=temp2*m[temp2];
- if(tsum<zsum)
- {
- cout<<tsum<<endl;
- return 0;
- }
- else
- {
- cout<<zsum<<endl;
- return 0;
- }
- }
- else if(s.size()==4)
- {
- //std::set<int>::iterator it;
- int tsum=0;
- for(it=s.begin();it!=s.end();it++)
- {
- int temp=*it;
- if(m[temp]==1)tsum+=temp;
- }
- cout<<tsum<<endl;
- return 0;
- }
- else if(s.size()==3)
- {
- // std::set<int>::iterator it;
- int tsum=0;
- for(it=s.begin();it!=s.end();it++)
- {
- int temp=*it;
- if(m[temp]==1){tsum+=temp;s.erase(it);}
- }
- //std::set<int>::iterator it;
- if(s.size()==2)
- {
- it=s.begin();
- int temp1=*it;
- it++;
- int temp2=*it;
- int zsum=tsum;
- tsum+=temp1*2;
- zsum+=temp2*2;
- if(tsum<zsum)
- {
- cout<<tsum<<endl;
- return 0;
- }
- else
- {
- cout<<zsum<<endl;
- return 0;
- }
- }
- cout<<tsum<<endl;
- return 0;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement