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: Accepted

Solution code:
#!/usr/bin/env python3

import sys
from typing import Any, Callable, Deque, Dict, List, Mapping, Optional, Sequence, Set, Tuple, TypeVar, Union
# import time
# import math, cmath
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import _heapify_max, _heappop_max, _siftdown_max
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import Fraction               # Fraction(a, b) => a / b ∈ Q. note: Fraction(0.1) do not returns Fraciton(1, 10). Fraction('0.1') returns Fraction(1, 10)



def main():
    Num = Union[int, float]
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79e+308
    # inf = 2 ** 63 - 1             # (for fast JIT compile in PyPy) 9.22e+18
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input():  return sys.stdin.readline().rstrip()
    def ii():     return int(input())
    def isp():    return input().split()
    def mi():     return map(int, input().split())
    def mi_0():   return map(lambda x: int(x)-1, input().split())
    def lmi():    return list(map(int, input().split()))
    def lmi_0():  return list(map(lambda x: int(x)-1, input().split()))
    def li():     return list(input())
    def debug(x): print(x, file=sys.stderr)
    # def _heappush_max(h, item): h.append(item); _siftdown_max(h, 0, len(h)-1)
    
    
    n = ii()
    a, b = mi()
    L = lmi()
    x, y, z = 0, 0, 0
    for num in L:
        if num <= a:
            x += 1
        elif num <= b:
            y += 1
        else:
            z += 1
    print(min(x, y, z))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
a, b = map(int, input().split())
p = list(map(int, input().split()))
cnt1 = 0
cnt2 = 0
cnt3 = 0
for i in p:
    if i <= a:
        cnt1 += 1
    elif i <= b:
        cnt2 += 1
    else:
        cnt3 += 1
ans = min(cnt1, cnt2, cnt3)
print(ans)

Submission status: Accepted

Solution code:
from bisect import bisect_right
n = int(input())
a, b = map(int, input().split())
p = list(map(int, input().split()))
p.sort()

idx_a = bisect_right(p, a)
idx_b = bisect_right(p, b)

ans = min(idx_a, idx_b - idx_a, n - idx_b)
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a,b, = map(int,input().split())
p = list(map(int,input().split()))
cnt = [0]*3
for i in range(n):
    if p[i] <= a:
        cnt[0] += 1
    elif p[i] <= b:
        cnt[1] += 1
    else:
        cnt[2] += 1
print(min(cnt))

Submission status: Accepted

Solution code:
N = int(input())
A,B = map(int,input().split())
P = list(map(int,input().split()))
n1 = 0
n2 = 0
n3 = 0
for i in P:
  if i <= A:
    n1 += 1
  elif i <= B:
    n2 += 1
  else:
    n3 += 1
print(min(min(n1,n2),n3))

Submission status: Accepted

Solution code:
n=int(input())
a,b=map(int,input().split())
p=list(map(int,input().split()))
q1=0
q2=0
q3=0
for i in range(n):
    if p[i]<=a:
        q1+=1
    elif a<p[i]<=b:
        q2+=1
    elif b<p[i]:
        q3+=1
print(min(q1,q2,q3))

Submission status: Accepted

Solution code:
n = int(input())
a, b = map(int, input().split())
P = list(map(int, input().split()))

problem = [0, 0, 0]
for p in P:
    if p <= a:
        problem[0] += 1
    elif p <= b:
        problem[1] += 1
    else:
        problem[2] += 1

print(min(problem))

Submission status: Accepted

Solution code:
N = int(input())
A,B = map(int,input().split())
P = list(map(int,input().split()))
P.sort()
count1,count2,count3 = 0,0,0
for i in range(N):
  if P[i] <= A:
    count1 += 1
  if P[i] >= B+1:
    count3 += 1
    continue
  if P[i] >= A+1:
    count2 += 1
print(min(count1,count2,count3))

Submission status: Accepted

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

cnt1=0
cnt2=0
cnt3=0
for i in range(n):
    if p[i]<=a:
        cnt1+=1
    elif a<p[i]<=b:
        cnt2+=1
    else:
        cnt3+=1
print(min([cnt1,cnt2,cnt3]))

Submission status: Accepted

Solution code:
import sys
N=int(input())
A,B=map(int,input().split())
P=list(map(int,input().split()))
a=0
b=0
c=0
for x in range(N):
  if P[x]<=A:
    a+=1
  elif P[x]>A and P[x]<=B:
    b+=1
  elif P[x]>B:
    c+=1
  else:
    sys.stderr.write("error")
print(min(a,b,c))

Submission status: Accepted

Solution code:
n = int(input())
a,b = map(int, input().split())
l = map(int, input().split())
x,y,z = 0,0,0
for i in l:
  if i<=a:
    x+=1
  elif i>a and i<=b:
    y+=1
  elif i>b:
    z += 1
print(min(x,min(y,z)))

Submission status: Accepted

Solution code:
n = int(input())
a,b = map(int,input().split())
P = list(map(int,input().split()))

Q = [0]*3
for i in range(n):
  if P[i] <= a:
    Q[0] += 1
  elif P[i] <= b:
    Q[1] += 1
  else:
    Q[2] += 1
    
print(min(Q))

Submission status: Accepted

Solution code:
n = int(input())
a,b = map(int,input().split())
p = list(map(int,input().split()))
x = 0
y = 0
z = 0

for i in range(n):
    if p[i] <= a:
        x += 1
    elif a + 1 <= p[i] and p[i] <= b:
        y += 1
    else:
        z += 1

print(min(x,y,z))

Submission status: Accepted

Solution code:
N = int(input())
A, B = map(int, input().split())
p = list(map(int, input().split()))
a, b, c = 0, 0, 0
for i in p:
    if i <= A: a += 1
    elif i <= B: b += 1
    else: c += 1
print(min(a, b, c))

Submission status: Accepted

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

for x in P:
	if x<=A:
		q1 += 1
	elif x<=B:
		q2 += 1
	else:
		q3 += 1

print(min(q1,q2,q3))

Submission status: Accepted

Solution code:
N=int(input())
x,y = map(int,input().split())
p = list(map(int,input().split()))

a=0
b=0
c=0

for i in range(N):
  if p[i]<=x:
    a+=1
  elif p[i]>=y+1:
    c+=1
  else:
    b+=1

print(min([a,b,c]))

Submission status: Accepted

Solution code:
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
a,b=nii()
p=lnii()

x=0
y=0
z=0

for i in p:
  if i<=a:
    x+=1
  elif i>=b+1:
    z+=1
  else:
    y+=1

print(min(x,y,z))

Submission status: Accepted

Solution code:
# Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
# }}} End Header
# _________コーディングはここから！！___________
n = int(input())
a, b = map(int, input().split())
p = list(map(int, input().split()))
k=0
l=0
m=0
for x in p:
    if x<=a: k+=1
    elif x>=a+1 and x<=b: l+=1
    elif x>=b+1: m+=1
print(min(k, l, m))

Submission status: Accepted

Solution code:
n=int(input())
a,b=map(int,input().split())
p=list(map(int,input().split()))
ta=0
tb=0
tc=0
for i in range(n):
  if p[i]<=a:
    ta=ta+1
  elif p[i]>=b+1:
    tc=tc+1
  else:
    tb=tb+1
print(min(ta,tb,tc))

Submission status: Accepted

Solution code:
N=int(input())
A,B=map(int,input().split())
P=list(map(int,input().split()))
a=0
b=0
c=0
for num in P:
    if num<=A:
        a+=1
    elif A<num<=B:
        b+=1
    else:
        c+=1

print(min(a,b,c))

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    A, B = (int(i) for i in input().split())
    P = [int(i) for i in input().split()]

    cnt = [0]*3
    for p in P:
        if p <= A:
            cnt[0] += 1
        elif p <= B:
            cnt[1] += 1
        else:
            cnt[2] += 1

    print(min(cnt))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    N = int(input())
    A,B= map(int, input().split())
    P = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    c0=c1=c2=0
    for p in P:
        if p<=A:
            c0+=1
        elif p<=B:
            c1+=1
        else:
            c2+=1
    print(min(c1,c2,c0))




if __name__ == "__main__":
    main()

Submission status: Accepted

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

c = [0] * 3
for P in map(int, input().split()):
    if P <= A:
        c[0] += 1
    elif A < P <= B:
        c[1] += 1
    else:
        c[2] += 1

print(min(c))

Submission status: Accepted

Solution code:
def main():
    n=int(input())
    a,b=map(int,input().split())
    p=map(int,input().split())
    A,B,C = 0,0,0
    for pp in p:
        if pp <= a:
            A += 1
        elif pp <= b:
            B += 1
        else:
            C += 1
    print(min(A,B,C))

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    n=int(input())
    a,b=map(int, input().split())
    p = map(int,input().split())
    A,B,C = 0, 0, 0
    for pp in p:
        if pp <= a:
            A += 1
        elif pp <= b:
            B += 1
        else:
            C += 1
    print(min(A,B,C))
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
A,B = map(int,input().split())
P = list(map(int,input().split()))
#P.sort()
q1 = []
q2 = []
q3 = []
for i in range(N):
  if P[i] <= A:
    q1.append(P[i])
  elif P[i] <= B:
    q2.append(P[i])
  else:
    q3.append(P[i])
print(min(len(q1),len(q2),len(q3)))

Submission status: Accepted

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

first_cnt = 0
second_cnt = 0
third_cnt = 0

for i in range(N):
    if P[i] <= A:
        first_cnt += 1
    elif P[i] <= B:
        second_cnt += 1
    else:
        third_cnt += 1

print(min(first_cnt, second_cnt, third_cnt))

Submission status: Accepted

Solution code:
N,A,B,*P=map(int,open(0).read().split())
C=[0]*3
for p in P:
    C[(A<p)+(B<p)]+=1
print(min(C))

Submission status: Accepted

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

X=Y=Z=0
for p in P:
    if p<=A:
        X+=1
    elif B<p:
        Z+=1
    else:
        Y+=1

print(min([X,Y,Z]))

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n=II()
    a,b=MI()
    pp=MI()
    cnt=[0]*3
    for p in pp:
        if p>b:cnt[0]+=1
        elif p>a:cnt[1]+=1
        else:cnt[2]+=1
    print(min(cnt))

main()

Submission status: Accepted

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

res = [0]*3

for v in p:
    if v <= a:
        res[0]+=1
    elif a < v <= b:
        res[1]+=1
    else:
        res[2]+=1
print(min(res))

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    a, b = list(map(int, input().split()))
    P = list(map(int, input().split()))
    ans = [[] for _ in range(3)]
    for p in P:
        if p <= a:
            ans[0].append(p)
        elif a + 1 <= p <= b:
            ans[1].append(p)
        else:
            ans[2].append(p)
    print(min(list(map(len, ans))))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
a,b = map(int,input().split())
L = list(map(int,input().split()))

p,q,r = [],[],[]
for i in range(n):
    if 0<=L[i]<=a:
        p.append(L[i])
    elif a+1 <= L[i] <=b:
        q.append(L[i])
    else:
        r.append(L[i])
print(min(len(p),len(q),len(r)))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    A,B=MI()
    P=LI()
    P.sort()
    L=[0,0,0]
    for i in range(N):
        if P[i]<=A:
            L[0]+=1
        elif A+1<=P[i]<=B:
            L[1]+=1
        else:
            L[2]+=1
            
    print(min(L))
            
    

main()

Submission status: Accepted

Solution code:
n = int(input())
a, b = map(int, input().split())
P = list(map(int, input().split()))

x = 0
y = 0
z = 0
for p in P:
    if p <= a:
        x += 1
    elif a+1 <= p <= b:
        y += 1
    else:
        z += 1
print(min([x, y, z]))

Submission status: Accepted

Solution code:
n=int(input())
a,b=map(int,input().split())
x,y,z=0,0,0
lst=list(map(int,input().split()))
for i in lst:
  if i<=a:
    x+=1
  elif a<i<=b:
    y+=1
  else:
    z+=1
o=[x,y,z]
print(min(o))

Submission status: Accepted

Solution code:
N = int(input())
A,B = map(int,input().split())
P = list(map(int,input().split()))
x = 0
y = 0
z = 0
for i in range(N):
  if(P[i]<=A):
    x+=1
  elif P[i]<=B:
    y+=1
  else:
    z+=1
print(min(x,y,z))

Submission status: Accepted

Solution code:
n = int(input())
a, b = map(int, input().split())
lst = list(map(int, input().split()))
diff = [0] * 3
for i in range(n):
  if lst[i] <= a:
    diff[0] += 1
  elif lst[i] <= b:
    diff[1] += 1
  else:
    diff[2] += 1
print(min(diff))

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A, B = MAP()
P = LIST()
L = [-1, A, B, 20]
print(min(map(len, [[x for x in P if L[i] < x <= L[i+1]] for i in range(3)])))

Submission status: Accepted

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

cnt=[0,0,0]
for poi in p:
  if poi <= a:
  	cnt[0]+=1
  elif poi <=b:
    cnt[1]+=1
  else:
    cnt[2]+=1
print(min(cnt))

Submission status: Accepted

Solution code:
n, a, b, *P = map(int, open(0).read().split())
cnt = [0]*3
for p in P:
    if p <= a:
        cnt[0] += 1
    elif a < p <= b:
        cnt[1] += 1
    else:
        cnt[2] += 1
print(min(cnt))

Submission status: Accepted

Solution code:
n=int(input())
a,b=map(int, input().split())
p=list(map(int, input().split()))
c=[0]*3
for i in p:
       if i <=a:
        c[0] +=1
       elif i>b:
        c[2] +=1
       else:
        c[1]+=1
print(min(c))

Submission status: Accepted

Solution code:
n = int(input())
a,b = map(int,input().split())
l = list(map(int,input().split()))
c = [0,0,0]
for i in l:
    if i <= a:
        c[0] += 1
    elif i > b:
        c[2] += 1
    else:
        c[1] += 1
print(min(c))

Submission status: Accepted

Solution code:
n = int(input())
a,b = map(int,input().split())
l = list(map(int,input().split()))
c = [0]*3
for i in l:
    if i <= a:
        c[0] += 1
    elif i > b:
        c[2] += 1
    else:
        c[1] += 1
print(min(c))

Submission status: Accepted

Solution code:
n = int(input())
a, b = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
c = 0
d = 0
e = 0
for i in range(n):
  if p[i] <= a:
    c += 1
  elif a + 1 <= p[i] <= b:
    d += 1
  elif p[i] >= b + 1:
    e += 1
ans = min(c, d, e)
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
A, B = [int(_) for _ in stdin.readline().rstrip().split()]
P = [int(_) for _ in stdin.readline().rstrip().split()]
a, ab, b = 0, 0, 0
for p in P:
    if p <= A:
        a += 1
    elif A < p <= B:
        ab += 1
    elif B < p:
        b += 1
print(min(a, ab, b))

Submission status: Accepted

Solution code:
N = int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))
lst = [0, 0, 0]
for p in P:
    if p <= A:
        lst[0] += 1
    elif p <= B:
        lst[1] += 1
    else:
        lst[2] += 1

print (min(lst))

Submission status: Accepted

Solution code:
def resolve():
    N = int(input())
    A, B = map(int, input().split())
    P = list(map(int, input().split()))
    ans = [0, 0, 0]
    for i in range(N):
        if P[i] <= A:
            ans[0] += 1
        elif P[i] >= B+1:
            ans[2] += 1
        else:
            ans[1] += 1
    print(min(ans))
resolve()

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N = INT()
A, B = MAP()
P = LIST()

a = [0]*3

for x in P:
	if x <= A:
		a[0] += 1
	elif B < x:
		a[2] += 1
	else:
		a[1] += 1

print(min(a))

Submission status: Accepted

Solution code:
n=int(input())
a,b=map(int,input().split())
l=list(map(int,input().split()))

c0=0
c1=0
c2=0
for i in range(n):
    if l[i]<=a:
        c0+=1
    if a<l[i]<=b:
        c1+=1
    if l[i]>b:
        c2+=1
print(min(c0,c1,c2))

Submission status: Accepted

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

num1 = len([x for x in p if x <= a])
num2 = len([x for x in p if a < x <= b])
num3 = len([x for x in p if b < x])

print(min(num1, num2, num3))

Submission status: Accepted

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

low, middle, high = 0, 0, 0
for i in range(N):
    if P[i] <= A:
        low += 1
    elif P[i] <= B:
        middle += 1
    else:
        high += 1
print(min(low, middle, high))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############
dic = DD(int)
N = I()
A,B = IL()
P = IL()

for p in P:
  if p<=A:
    dic[0] += 1
  elif p>B:
    dic[2] += 1
  else:
    dic[1] += 1
print(min(dic[0],dic[1],dic[2]))

Submission status: Accepted

Solution code:
n = int(input())
a, b = map(int,input().split())
li = list(map(int,input().split()))
x = 0
y = 0
z = 0

for i in li:
    if i <= a:
        x += 1
    elif i <= b:
        y += 1
    else:
        z += 1

print(min(x,y,z))

Submission status: Accepted

Solution code:
n=int(input())
a,b=map(int,input().split())
p=list(map(int,input().split()))
num1=0
num2=0
num3=0
for i in range(n):
    if p[i]<=a:
        num1+=1
    elif p[i]<=b:
        num2+=1
    else:
        num3+=1
print(min(num1,num2,num3))

Submission status: Accepted

Solution code:
from collections import deque
N=int(input())
a,b=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
ans=0
x=0
y=0
z=0
for i in range(N):
    if p[i]<=a:
        x+=1
    if a+1<=p[i]<=b:
        y+=1
    if p[i]>=b+1:
        z+=1
print(min(x,y,z))

Submission status: Accepted

Solution code:
n = int(input())
a, b = map(int, input().split())
p = list(map(int, input().split()))
A, B, C = [], [], []
for i in p:
    if i <= a:
        A.append(i)
    elif i <= b:
        B.append(i)
    else:
        C.append(i)
print(min(len(A), len(B), len(C)))

Submission status: Accepted

Solution code:
n=int(input())
a,b=map(int,input().split())
p=sorted(list(map(int,input().split())))
x,y=-1,-1
for i in range(n):
    if x==-1 and p[i]>a:
        x=i
    if y==-1 and p[i]>b:
        y=i
if x==-1 or y==-1:
    print(0)
    exit()
print(min(x,y-x,n-y))

Submission status: Accepted

Solution code:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A,B = readInts()
P = sorted(readInts())
i = 0
nya = 0
ans = 0
while i < n:
    if nya == 0:
        if 1 <= P[i] <= A:
            nya = 1
            P[i] = -1
    elif nya == 1:
        if A < P[i] <= B:
            nya = 2
            P[i] = -1
    elif nya == 2:
        if B < P[i]:
            nya = 0
            P[i] = -1
            ans += 1
            i = 0
    i += 1
#print(P)
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
A,B=map(int,input().split())
P=list(map(int,input().split()))
  
s=0
t=0
u=0
  
for q in P:
  if q<=A:
    s += 1
  elif A+1<=q<=B:
    t += 1
  else:
    u += 1
print(min(s,t,u))

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    problem1, problem2, problem3 = [], [], []
    for p in P:
        if p <= A:
            problem1.append(p)
        elif A + 1 <= p <= B:
            problem2.append(p)
        else:
            problem3.append(p)

    res = min(len(problem1), len(problem2), len(problem3))
    print(res)


if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
import bisect
n = int(input())
a,b = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
a_ = bisect.bisect_right(p,a)
b_ = bisect.bisect_right(p,b)
print(min(a_,b_-a_,n-b_))