Can someone explain why my solution is wrong ?
problem : CodeChef | Competitive Programming | Participate & Learn
solution : CodeChef | Competitive Programming | Participate & Learn
Can someone explain why my solution is wrong ?
problem : CodeChef | Competitive Programming | Participate & Learn
solution : CodeChef | Competitive Programming | Participate & Learn
your code failed in this case:
1
3
1 2 2
should be Marichka. Marichka take 1, no matter what Zenyk take, Marichka will win
#include
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while (t–)
{
int n;
cin>>n;
int a[n];
map<int,int>mp;
for(int i=0;i<n;i++)cin>>a[i];
sort(a,a+n);
int flag=1;
for(int i=n-1;i>=0;i–)mp[a[i]]++;
if(mp[a[n-1]]%2==0)cout<<“Zenyk\n”;
else cout<<“Marichka\n”;
}
return 0;
}
why this not running and why editorial is checking for all elements if if can see only the count of largest element if odd then marchika and if even then zenyk…
send link to your solution
thanks @henrychen . My logic was wrong.