Problem:


Score : 200 points

Problem Statement

You have written N problems to hold programming contests.
The i-th problem will have a score of P_i points if used in a contest.

With these problems, you would like to hold as many contests as possible under the following condition:

A contest has three problems. The first problem has a score not greater than A points, the second has a score between A + 1 and B points (inclusive), and the third has a score not less than B + 1 points.

The same problem should not be used in multiple contests.
At most how many contests can be held?

Constraints

3 \leq N \leq 100

1 \leq P_i \leq 20 (1 \leq i \leq N)

1 \leq A < B < 20

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A B
P_1 P_2 ... P_N

Output

Print the answer.

Sample Input 1

7
5 15
1 10 16 2 7 20 12

Sample Output 1

2

Two contests can be held by putting the first, second, third problems and the fourth, fifth, sixth problems together.

Sample Input 2

8
3 8
5 5 5 10 10 10 15 20

Sample Output 2

0

No contest can be held, because there is no problem with a score of A = 3 or less.

Sample Input 3

3
5 6
5 6 10

Sample Output 3

1



Sample input:
7
5 15
1 10 16 2 7 20 12


Sample output:
2

Submission status: Runtime Error

Solution code:
# coding: utf-8

n = int(input())
a,b = map(int,input().split())
p = list(map(int,input().split()))

p.sort()

sep = []
for i in range(0,n):
    if(p[i] > a):
        sep.append(i)
        break
for i in range(sep[0],n):
    if(p[i] > b):
        sep.append(i)
        break

q1 = len(p[0:sep[0]])
q2 = len(p[sep[0]:sep[1]])
q3 = len(p[sep[1]:n])


#print("{}, {}, {}".format(q1,q2,q3))
print(min(q1,q2,q3))

Submission status: Runtime Error

Solution code:
# coding: utf-8

n = int(input())
a,b = map(int,input().split())
p = list(map(int,input().split()))

p.sort()

sep = []
for i in range(0,n-1):
    if(p[i] > a):
        sep.append(i)
        break
for i in range(sep[0],n-1):
    if(p[i] > b):
        sep.append(i)
        break

q1 = len(p[0:sep[0]])
q2 = len(p[sep[0]:sep[1]])
q3 = len(p[sep[1]:n])


#print("{}, {}, {}".format(q1,q2,q3))
print(min(q1,q2,q3))

Submission status: Runtime Error

Solution code:
a = int(input())
b,c = map(int,input().split())
lis = input().split()

li = [int(l) for l in lis]

judge = True

d = 0

li.sort()

while judge:
    
    s = []
    s.append(min(li))
    li.remove(min(li))

    for n in li:
        if n >= b+1 and n<=c:
            s.append(n)
            li.remove(n)
            break
        else:judge = False

    for n in li:
        if n>=c+1:
            s.append(n)
            li.remove(n)
            break
        else:
            judge= False

    if len(s) == 3:
        d+=1
        judge = True
    else:judge=False

print(d)

Submission status: Runtime Error

Solution code:
n = int(input())
a, b = list(map(int, input().split()))
p = list(map(int, input().split()))
cnta = 0
cntb = 0
cnt c = 0
for pi in p:
  if pi <= a:
    cnta += 1
  elif pi <= b:
    cntb += 1
  else:
    cntc += 1
ans = min(cnta, cntb, cntc)
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
h=int(input())
w=int(input())

print((n-h+1)*(n-w+1))

Submission status: Runtime Error

Solution code:
n = int(input())
a, b = map(int, input().split())
p = list(map(int, input().split())
count = []

for i in n:
    if 1<= p[i] and p[i] <= 5:
        count1 += 1
    elif 6 <= p[i] and p[i] <=15:
        count2 += 1
    elif 16 <= p[i] and p[i] <=19:
        count3 += 1

count.append(count1)
count.append(count2)
count.append(count3)

print(min(count))

Submission status: Runtime Error

Solution code:
# _*_ coding:utf-8 _*_
#  Atcoder_AISingProgramming_Contest-B
#  TODO https://aising2019.contest.atcoder.jp/tasks/aising2019_b

def solveProblem(problemSeed,FirstScore,SecondScore,ScoreList):
	firstBarrier = 0
	secondBarrier = 0
	lastBarrier = 0
	for problemNo in range(0,len(ScoreList),+1):
		problemScore = ScoreList(problemNo)
		if problemScore <= FirstScore:
			firstBarrier = firstBarrier + 1
		elif ( FirstScore+1 <= problemScore ) and ( problemScore <= SecondScore):
			secondBarrier = secondBarrier + 1
		else : # secondScore + 1 <= problemScore
			lastBarrier = lastBarrier + 1
	problemPattern = firstBarrier * secondBarrier * lastBarrier
	answer = problemPattern
	return answer


if __name__ == '__main__':
	N = int(input().strip())
	A,B = map(int,input().strip().split(' '))
	Ps = list(map(int,input().strip().split(' ')))
	solution = solveProblem(N,A,B,Ps)
	print("{}".format(solution))

Submission status: Runtime Error

Solution code:
n = int(input())
ab = input().rstrip().split()
p = input().rstrip().split()
c=0 
i = 1
for i in range(n):
  j=i-1
  for j in range(n):
    if(p[j] > p[i]):
      temp = p[j]
      p[j] = p[i]
      p[i] = temp
i = 0
for i in range(n):
  p[i] = int(p[i])
a=int(ab[0])
b=int(ab[1])
i = 0
j = 0
k = 0
for i in range(n):
  if(p[i] <= a and p[i] < 21):
    j = i + 1
    for j in range(n):
      if(p[j] <= b and p[j] >= a+1):
        k = j + 1 
        for k in range(n):
          if(p[k] >= b+1):
            c = c + 1
            p[i]=21
            p[j]=21
            p[k]=21
            flag = 1
            break
        if(flag == 1):
          flag = 0
          break

print(c)

Submission status: Runtime Error

Solution code:
n = int(input())
a, b = map(int,input().split())
listP=list(map(int,input().split()))
num0 = sum(listP<=a)
num1 = sum(listP<=b) - num0
num2 = sum(listP>b)
print(min([num0,num1,num2]))

Submission status: Runtime Error

Solution code:
n = int(input())
ab = input().rstrip().split()
p = input().rstrip().split()
c=0 
i = 1
for i in range(n):
  j=i-1
  for j in range(n):
    if(p[j] > p[i]):
      temp = p[j]
      p[j] = p[i]
      p[i] = temp
i = 0
for i in range(n):
  p[i] = int(p[i])
a=int(ab[0])
b=int(ab[1])
i = 0
j = 0
k = 0
for i in range(n):
  if(p[i] <= a and p[i] > 0):
    j = i + 1
    for j in range(n):
      if(p[j] <= b and p[j] >= a+1):
        k = j + 1 
        for k in range(n):
          if(p[k] >= b+1):
            c = c + 1
            p[i]=0 
            p[j]=0
            p[k]=0
            flag = 1
            break
        if(flag == 1):
          flag = 0
          break

print(c)

Submission status: Runtime Error

Solution code:
N = int(input())
A, B = [int(_) for i in input().split()]
P =  [int(_) for i in input().split()] 
x = len([i for i in P if i <= A])
y = len([i for i in P if i <= B and i >= A+1])
z = len([i for i in P if i <= B])

if x != 0 and y != 0 and z != 0:
    print(min([x,y,z]))
else :
    print(0)

Submission status: Runtime Error

Solution code:
n = int(input())
ab = input().rstrip().split()
p = input().rstrip().split()
c=0 
i = 1
for i in range(n):
  j=i-1
  for j in range(n):
    if(p[j] > p[i]):
      temp = p[j]
      p[j] = p[i]
      p[i] = temp
i = 0
for i in range(n):
  p[i] = int(p[i])
a=int(ab[0])
b=int(ab[1])
i = 0
j = 0
k = 0
for i in range(n):
  if(p[i] <= a and p[i]!=0):
    j = i + 1
    for j in range(n):
      if(p[j]<=b and p[j] >= a+1 and p[j]!=0):
        k = j + 1 
        for k in range(n):
          if(p[k] >= b+1 and p[k]!=0):
            c = c + 1
            p[i]=0 
            p[j]=0
            p[k]=0
            flag = 1
            break
        if(flag == 1):
          flag = 0
          break

print(c)

Submission status: Runtime Error

Solution code:
N = int(input())
A = int(input())
B = int(input())
num = []*3
for i in range(N):
    score = int(input())
    if (score <= A):
        num[0] += 1
    elif(score <= B):
        num[1] += 1
    else:
        num[2] +=1
max_value = 0
for i in range(3):
    if max_value < num[i]:
        max_value = num[i]
print(max_value)

Submission status: Runtime Error

Solution code:
import copy

N = int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))

al = []
bl = []
cl = []

for x in P:
    if x <= A:
        al.append(x)
    elif A+1 <= x and x <= B:
        bl.append(x)
    else:
        cl.append(x)

btbl = [[] for i in range(len(bl))]
for b in range(len(bl)):
    for c in cl:
        if bl[b] < c:
            btbl[b].append(c)

temp = 0
for i in range(1, len(btbl)):
    if btbl[temp] > btbl[i]:
        temp = i

temp_btbl = copy.deepcopy(btbl[temp])

print(min(len(al), len(temp_btbl)))

Submission status: Runtime Error

Solution code:
N = int(input())
A = int(input())
B = int(input())
num = []*3
for i in range(N):
    score = int(input())
    if (score <= A):
        num[0] += 1
    elif(score <= B):
        num[1] += 1
    else:
        num[2] +=1
print(min(num))

Submission status: Runtime Error

Solution code:
N = int(input())
A,B = map(int,input().split())
P =list(map(int, input().split()))
P=sorted(P)
for i in range(N):
    if P[i]>A:
        x=i
        break
for i in range(N):
    if P[i]>B:
        y=i
        break
if x==0 or y-x==0 or N-y==0:
    print(0)
else:
    print(min(x,y-x,N-y))

Submission status: Runtime Error

Solution code:
N=int(input())
A,B=list(map(int,input().split()))
P=list(map(int,input().split()))

P.sort()

na=0

while P[na] < A+1:
    na=na+1

nb=na

while P[nb] < B+1:
    nb=nb+1

nb=nb-na

nc=N-nb

n=[na,nb,nc]
n.sort()

print(n[0])

Submission status: Runtime Error

Solution code:
N=int(input())
A,B=list(map(int,input().split()))
P=list(map(int,input().split()))

P.sort()

na=0

while P[na] < A+1:
    na=na+1

nb=0

while P[nb] < B+1:
    nb=nb+1

nb=nb-na

nc=N-nb

n=[na,nb,nc]
n.sort()

print(n[0])

Submission status: Runtime Error

Solution code:
N = int(input())
A,B =  map(int,input().split())
P = list(map(int,input().split()))

P.sort()

comb = 0
cont = 0

for i in range(0,len(P)-1):
    if comb == 0 and P[i] <= A:
        comb += 1
        now_i = i
        while P[now_i+1] == P[now_i]:
            cont += 1
            now_i += 1
    if comb == 1 and P[i] >= A+1 and P[i] <= B:
        comb += 1
        now_i = i
        while P[now_i+1] == P[now_i]:
            cont += 1
            now_i += 1
    if comb == 2 and P[i] >= B+1:
        comb += 1
        now_i = i
        while P[now_i+1] == P[now_i]:
            cont += 1
            now_i += 1
    if comb == 3:
        cont += 1
        now_i = i
        while P[now_i+1] == P[now_i]:
            cont += 1
            now_i += 1

if comb == 0 and P[-1] <= A:
    comb += 1
    now_i = i
if comb == 1 and P[-1] >= A+1 and P[-1] <= B:
    comb += 1
    now_i = i
if comb == 2 and P[-1] >= B+1:
    comb += 1
    now_i = i
if comb == 3:
    cont += 1
    now_i = i


print(cont)

Submission status: Runtime Error

Solution code:
N = int(input())
A,B = map(int,input().split())
P =list(map(int, input().split()))
P=sorted(P)
for i in range(N):
    if P[i]>A:
        x=i
        break
for i in range(N):
    if P[i]>B:
        y=i
        break
print(min(x,y-x,N-y))

Submission status: Runtime Error

Solution code:
N=int(input())
A,B  = list(map(int, input().split()))
lis = list(map(int, input().split()))
lis_1=[]
lis_2=[]
lis_3=[]
for i in lis:
    if i <= A:
       lis_1.append(i)
    elif i > A and i <=B:
       lis_2.append(i)
    else:
       lis_3.append(i)

print(min[len(lis_1),len(lis_2),len(lis_3)])

Submission status: Runtime Error

Solution code:
N=int(input())
A,B  = list(map(int, input().split()))
lis = list(map(int, input().split()))
lis_1=[]
lis_2=[]
lis_3=[]
for i in lis:
   if i <= A:
      lis_1.append(i)
   elif i > A and i <=B:
      lis_2.append(i)
   else:
      lis_3.append(i)

print(min[len(lis_1),len(lis_2),len(lis_3)])

Submission status: Runtime Error

Solution code:
N = int(input())
A, B = map(int,input().split())
P = list(map(int,input().split()))

cnt = 0
for i in range(N):
  if(P[i] <= A):
    if(A+1 <= P[i+1] <= B):
      if(P[i+2] >= B+1):
        cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
N=int(input())
A,B  = list(map(int, input().split()))
lis = list(map(int, input().split())))
lis_1=[]
lis_2=[]
lis_3=[]
for i in lis:
   if i <= A:
      lis_1.append(i)
   elif i > A and i <=B:
      lis_2.append(i)
   else:
      lis_3.append(i)

print(min[len(lis_1),len(lis_2),len(lis_3)])