Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int sum;
- int cnt[105];
- int maxInd;
- vector<int> cards;
- void init();
- void solve();
- int main()
- {
- init();
- int temp;
- for(int i = 1; i <= 5; i++)
- {
- cin >> temp;
- cards.push_back(temp);
- sum += temp;
- } // end of for
- solve();
- return 0;
- }
- void init()
- {
- memset(cnt, 0, 105);
- sum = 0;
- maxInd = 0;
- }
- void solve()
- {
- int sz = cards.size();
- int val;
- for(int i = 0; i < sz; i++)
- {
- val = cards[i];
- cnt[val]++; // increase the count
- if(cnt[maxInd]*maxInd > cnt[val]*val && cnt[maxInd] > 1) continue;
- if(cnt[maxInd] < cnt[val])
- {
- maxInd = val;
- } // end of if
- else if(cnt[maxInd]*maxInd < cnt[val]*val && maxInd < val && cnt[val] > 1)
- {
- maxInd = val;
- } // end of if
- } // end of for
- if(cnt[maxInd] > 3) cnt[maxInd] = 3;
- if(cnt[maxInd] != 1)
- {
- sum -= cnt[maxInd]*maxInd;
- }
- cout << sum;
- }
Advertisement
Add Comment
Please, Sign In to add comment