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

1 Like

#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.