From 7cd7b069bc6b9401b8a2a5a46498672ed1454032 Mon Sep 17 00:00:00 2001 From: Jethro Stapelbroek Date: Wed, 25 May 2022 14:44:20 +0200 Subject: [PATCH] Array Smoothening (60/100) --- arraysmoothening.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 arraysmoothening.py diff --git a/arraysmoothening.py b/arraysmoothening.py new file mode 100644 index 0000000..62ac0a7 --- /dev/null +++ b/arraysmoothening.py @@ -0,0 +1,13 @@ +_, k = map(int, input().split()) +a = list(map(int, input().split())) +u = set(a) + +c = {} +for v in u: + c[v] = len([x for x in a if x == v]) + +for _ in range(k): + m = max(c, key=c.get) + c[m] -= 1 + +print(max(c.values())) \ No newline at end of file