# HIGHSCORE-Editorial

Setter: Utkarsh Gupta
Tester: Manan Grover, Lavish Gupta
Editorialist: Devendra Singh

672

None

# PROBLEM:

Chef is taking a tough examination. The question paper consists of N objective problems and each problem has 4 options A, B, C, and D, out of which, exactly one option is correct.

Since Chef did not study for the exam, he does not know the answer to any of the problems. Chef was looking nearby for help when his friend somehow communicated the following information:

• Exactly N_A problems have option A as the answer.
• Exactly N_B problems have option B as the answer.
• Exactly N_C problems have option C as the answer.
• Exactly N_D problems have option D as the answer.

Note that:

• N_A + N_B + N_C + N_D = N.
• Each problem is worth exactly 1 mark and there is no negative marking.
• Even though Chef knows the number of correct options of each type, he does not know the correct answer to any problem.

Based on the given information, find the maximum marks Chef can guarantee if he marks the answers optimally.

# EXPLANATION:

Even though Chef knows the number of correct options of each type, he does not know the correct answer to any problem. If chef marks all answers as A he gets exactly N_A marks. Similarly if chef marks all answers as B he gets exactly N_B marks and so on.
Hence to get maximum marks he should mark the option which is the correct option for maximum number of the problems.
\therefore ans=max(N_A,N_B,N_C,N_D)

# TIME COMPLEXITY:

O(1) for each test case.

# SOLUTION:

Setter's solution
``````//Utkarsh.25dec
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
long long readInt(long long l,long long r,char endd){
long long x=0;
int cnt=0;
int fi=-1;
bool is_neg=false;
while(true){
char g=getchar();
if(g=='-'){
assert(fi==-1);
is_neg=true;
continue;
}
if('0'<=g && g<='9'){
x*=10;
x+=g-'0';
if(cnt==0){
fi=g-'0';
}
cnt++;
assert(fi!=0 || cnt==1);
assert(fi!=0 || is_neg==false);

assert(!(cnt>19 || ( cnt==19 && fi>1) ));
} else if(g==endd){
if(is_neg){
x= -x;
}

if(!(l <= x && x <= r))
{
cerr << l << ' ' << r << ' ' << x << '\n';
assert(1 == 0);
}

return x;
} else {
assert(false);
}
}
}
string ret="";
int cnt=0;
while(true){
char g=getchar();
assert(g!=-1);
if(g==endd){
break;
}
cnt++;
ret+=g;
}
assert(l<=cnt && cnt<=r);
return ret;
}
long long readIntSp(long long l,long long r){
}
long long readIntLn(long long l,long long r){
}
}
}
void solve()
{
assert(a+b+c+d==n);
cout<<max({a,b,c,d})<<'\n';
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL),cout.tie(NULL);
//cin>>T;
while(T--)
solve();
assert(getchar()==-1);
cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}
``````
Editorialist's Solution
``````#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define pb push_back
#define all(_obj) _obj.begin(), _obj.end()
#define F first
#define S second
#define pll pair<ll, ll>
#define vll vector<ll>
const int N = 1e5 + 11, mod = 1e9 + 7;
ll max(ll a, ll b) { return ((a > b) ? a : b); }
ll min(ll a, ll b) { return ((a > b) ? b : a); }
void sol(void)
{
int n, a, b, c, d;
cin >> n >> a >> b >> c >> d;
cout << max(max(a, b), max(c, d)) << '\n';
return;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL), cout.tie(NULL);
int test = 1;
cin >> test;
while (test--)
sol();
}

``````