In this

**HackerEarth Bear and Medals problem solution**Limak is a little bear who loves sports. He has been waiting so long for the Day of Sport in his school. But it's today and he is late!The Day of Sports consists of a number of contests. In each competition, there are three medals - one gold, one silver, and one bronze. These medals are awarded to three different contestants and there are no ties. You can assume that there are at least three contestants so all three medals are always awarded.

Limak will get to a school in a moment but know he can only cheer for his friends. He has N friends and by phone, they have informed him about their achievements so far. Limak knows that i-th of his friends got G[i] golds, S[i] silvers, and B[i] bronzes.

Limak hopes he didn't skip many contests. He knows only the numbers of medals awarded to his friends. Help him and with this knowledge find the minimum possible number of contests Limak skipped.

## HackerEarth Bear and Medals problem solution.

```
#include<bits/stdc++.h>
using namespace std;
int main() {
int z;
scanf("%d", &z);
while(z--) {
int n;
scanf("%d", &n);
int color[3] = {0, 0, 0};
int result = 0;
while(n--) {
int person = 0;
for(int i = 0; i < 3; ++i) {
int a;
scanf("%d", &a);
person += a;
color[i] += a;
}
result = max(person, result);
}
for(int i = 0; i < 3; ++i)
result = max(result, color[i]);
printf("%d\n", result);
}
return 0;
}
```

### Second solution

```
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
int g[MAXN],s[MAXN],b[MAXN];
int main()
{
ios_base::sync_with_stdio(0);
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int g_tot = 0, s_tot = 0, b_tot = 0, ans = 0;
for (int i = 0; i < n; ++i)
{
cin>>g[i]>>s[i]>>b[i];
g_tot+=g[i];
s_tot+=s[i];
b_tot+=b[i];
ans = max(ans,g[i]+s[i]+b[i]);
}
ans = max(ans,g_tot);
ans = max(ans,s_tot);
ans = max(ans,b_tot);
cout<<ans<<"\n";
}
return 0;
}
```

## 0 Comments