MEENA_007 Editorial

PROBLEM LINK:

Practice

Author: Ram Agrawal
Tester: Yogesh Deolalkar
Editorialist:Prathamesh Sogale

DIFFICULTY:

CAKEWALK, SIMPLE.

PREREQUISITES:

Greedy, Math

PROBLEM:

Meena have prepared four problems. The difficulty levels of the problems are A1,A2,A3,A4 respectively. A problem set comprises at least two problems and no two problems in a problem set should have the same difficulty level. A problem can belong to at most one problem set. Find the maximum number of problem sets Meena can create using the four problems.

Given an array of integers of length N and a number k, write a program to print True if the given array can be divided into N/2 perfect pairs else print False.

SOLUTIONS:

Setter's Solution

cook your dish here

for i in range (int(input())):
a1,a2,a3,a4=map(int ,input().split())
a=list([a1,a2,a3,a4])
a.sort()
len1=len(set(a))
if len1==4 or len1==3:
print(2)
elif len1==2:
c=a.count(a[0])
if c==2:
print(2)
else:
print(1)
else:
print(0)

Tester's Solution

for t in range(int(input())):
a=list(map(int,input().split()))
a=sorted(a)
p=set(a)
r=“”
if len(p)==4:
print(2)
elif len(p)==3:
print(2)
elif len(p)==2:
for i in a:
r+=str(i)
r1=r.count(r[0])
r4=r.count(r[3])
if r1==2 and r4==2:
print(2)
else:
print(1)
elif len(p)==1:
print(0)