Topic Links:
A. Bear and Five Cards
//#include <bits/stdc++.h>#include <vector>#include<iostream>#include<queue>#include<cmath>#include<map>#include<cstring>#include<algorithm>#include<cstdio>using namespacestd;#defineRiep (n) for (int i=1;i<=n;i++)#defineRIOP (n) for (int i=0;i<n;i++)#defineRJEP (n) for (int j=1;j<=n;j++)#defineRJOP (n) for (int j=0;j<n;j++)#defineMST (SS,B) memset (ss,b,sizeof (ss));typedefLong Longll;template<classT>voidRead (t&num) { CharCH;BOOLf=false; for(Ch=getchar (); ch<'0'|| Ch>'9'; f= ch=='-', ch=GetChar ()); for(num=0; ch>='0'&&ch<='9'; num=num*Ten+ch-'0', ch=GetChar ()); F&& (num=-num);}intstk[ -], Tp;template<classT> Inlinevoidprint (T p) {if(!p) {Puts ("0");return; } while(p) stk[++ TP] = p%Ten, p/=Ten; while(TP) Putchar (stk[tp--] +'0'); Putchar ('\ n');}ConstLL mod=1e9+7;Const DoublePi=acos (-1.0);ConstLL inf=1e14;Const intn=1e5+ the;inta[Ten],flag[ $];intMain () {intsum=0; for(intI=1; i<=5; i++) read (A[i]), sum+=a[i],flag[a[i]]++; intans=sum; for(intI=1; i<=5; i++) { if(flag[a[i]]>1&&flag[a[i]]<4) ans=min (ans,sum-flag[a[i]]*A[i]); Else if(flag[a[i]]>3) {ans=min (ans,sum-3*A[i]); }} cout<<ans<<"\ n"; return 0;}
Codeforces 680A A. Bear and Five Cards (water problem)