Given an array Arr of N positive integers and a number K where K is used as a threshold value to divide each element of the array into sum of different numbers. Find the sum of count of the numbers in which array elements are divided.
Example 1:
Input:
N = 4, K = 3
Arr[] = {5, 8, 10, 13}
Output: 14
Explanation: Each number can be expressed as sum 
of different numbers less than or equal to K as
5 (3 + 2), 8 (3 + 3 + 2), 10 (3 + 3 + 3 + 1), 
13 (3 + 3 + 3 + 3 + 1). So, the sum of count 
of each element is (2+3+4+5)=14.
Example 2:
Input:
N = 5, K = 4
Arr[] = {10, 2, 3, 4, 7}
Output: 8
Explanation: Each number can be expressed as sum of
different numbers less than or equal to K as
10 (4 + 4 + 2), 2 (2), 3 (3), 4 (4) and 7 (4 + 3).
So, the sum of count of each element is 
(3 + 1 + 1 + 1 + 2) = 8.
Your Task:
You don't need to read input or print anything. Your task is to complete the function totalCount() which takes the array of integers arr and n as parameters and returns an integer denoting the answer.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ N ≤ 10^{7}
0 ≤ Arr_{i} ≤ 10^{7}
1 ≤ K ≤ 10^{7}

Source: geeksforgeeks | Difficulty: EASY
Tags: Data structures

Starter code: #User function Template for python3



class Solution:

    def totalCount(self, arr, n, k):

        # code here

Solutions:
class Solution:

	def totalCount(self, arr, n, k):
		l = []
		for i in arr:
			if i // k == i / k:
				l.append(i // k)
			else:
				l.append(i // k + 1)
		return sum(l)


class Solution:

	def totalCount(self, arr, n, k):
		sum = 0
		for i in range(n):
			sum += arr[i] // k + (arr[i] % k > 0)
		return sum


class Solution:

	def totalCount(self, arr, n, k):
		import math
		cnt = 0
		for i in arr:
			b = math.ceil(i / k)
			cnt += b
		return cnt


import math

class Solution:

	def totalCount(self, arr, n, k):
		answer = 0
		for i in range(n):
			element = arr[i]
			count = math.ceil(element / k)
			answer = answer + count
		return answer


class Solution:

	def totalCount(self, arr, n, k):
		count = 0
		for num in arr:
			if num > k and num % k != 0:
				count += num // k + 1
			elif num > k and num % k == 0:
				count += num // k
			else:
				count += 1
		return count


class Solution:

	def totalCount(self, arr, n, k):
		c = 0
		for i in range(n):
			while arr[i] > 0:
				arr[i] -= k
				c += 1
		return c


class Solution:

	def totalCount(self, arr, n, k):
		sum = 0
		for i in range(n):
			if arr[i] % k > 0:
				sum += 1
			sum = sum + arr[i] // k
		return int(sum)


class Solution:

	def totalCount(self, arr, n, k):
		cot = 0
		for num in arr:
			di = num // k
			rem = num % k
			if rem > 0:
				di += 1
			cot += di
		return cot


class Solution:

	def totalCount(self, arr, n, k):
		count = 0
		for i in range(n):
			if arr[i] % k == 0:
				count += arr[i] // k
			else:
				count += arr[i] // k + 1
		return count


class Solution:

	def totalCount(self, arr, n, k):
		s = 0
		for i in arr:
			if i % k == 0:
				s += i // k
			else:
				s += i // k + 1
		return s


class Solution:

	def totalCount(self, arr, n, k):
		R = 0
		for i in arr:
			R += i // k
			if i % k != 0:
				R += 1
		return R


class Solution:

	def totalCount(self, arr, n, k):
		count = 0
		for i in arr:
			rem = i % k
			mul = (i - rem) // k
			count += mul
			if rem > 0:
				count += 1
		return count


class Solution:

	def totalCount(self, arr, n, k):
		c = 0
		for p in arr:
			c += p // k
			if p % k > 0:
				c += 1
		return c


class Solution:

	def totalCount(self, arr, n, k):
		c = 0
		for i in arr:
			if i <= k:
				c += 1
			else:
				while i > 0:
					i -= k
					c += 1
		return c


class Solution:

	def totalCount(self, arr, n, k):
		count = 0
		for i in arr:
			temp = i
			while temp > k:
				temp = temp - k
				count = count + 1
			count += 1
		return count


class Solution:

	def totalCount(self, arr, n, k):
		cou = 0
		for i in range(n):
			cou += arr[i] // k
			if arr[i] % k != 0:
				cou += 1
		return cou


class Solution:

	def totalCount(self, arr, n, k):
		return sum([elem // k + (1 if elem % k != 0 else 0) for elem in arr])


import math

class Solution:

	def totalCount(self, arr, n, k):
		sum = 0
		for i in arr:
			sum += math.ceil(i / k)
		return sum


class Solution:

	def totalCount(self, arr, n, k):
		list_num = []
		for i in arr:
			quotient = i // k
			if i % k != 0:
				quotient += 1
			list_num.append(quotient)
		return sum(list_num)


class Solution:

	def totalCount(self, arr, n, k):
		ans = []
		for i in arr:
			if i < k:
				ans.append(1)
			elif i % k == 0:
				ans.append(i // k)
			else:
				ans.append(i // k + 1)
		return sum(ans)


class Solution:

	def totalCount(self, arr, n, k):
		p = []
		for i in range(n):
			z = arr[i]
			if arr[i] % k == 0:
				p.append(arr[i] // k)
			else:
				p.append(arr[i] // k + 1)
		return sum(p)


class Solution:

	def totalCount(self, arr, n, k):
		s = 0
		for i in arr:
			q = i // k
			r = i % k > 0
			s += q + r
		return s


class Solution:

	def totalCount(self, Arr, N, K):
		count = 0
		for i in range(N):
			count += (Arr[i] + K - 1) // K
		return count


class Solution:

	def totalCount(self, arr, n, k):
		count = 0
		for i in range(n):
			ele = arr[i]
			while ele > k:
				count += 1
				ele -= k
			count += 1
		return count


class Solution:

	def totalCount(self, arr, n, k):
		count = 0
		for i in range(n):
			a = []
			ele = arr[i]
			while ele > k:
				a.append(k)
				ele -= k
			a.append(ele)
			count += len(a)
		return count


class Solution:

	def totalCount(self, arr, n, k):
		res = 0
		for i in arr:
			quo = i // k
			if i % k != 0:
				res += quo + 1
			else:
				res += quo
		return res


class Solution:

	def totalCount(self, arr, n, k):
		count = 0
		for i in arr:
			count += int(i / k)
			if int(i % k) != 0:
				count += 1
		return count


class Solution:

	def totalCount(self, arr, n, k):
		countSum = 0
		for i in arr:
			div = i // k
			if i % k == 0:
				countSum += div
			else:
				countSum += div + 1
		return countSum


class Solution:

	def totalCount(self, arr, n, k):
		ans = 0
		for num in arr:
			if num % k == 0:
				ans += num // k
			else:
				ans += num // k + 1
		return ans


class Solution:

	def totalCount(self, arr, n, k):
		sum = 0
		for i in range(n):
			a = arr[i] // k
			b = arr[i] % k
			if b == 0:
				sum += a
			else:
				sum += a + 1
		return sum


class Solution:

	def totalCount(self, arr, n, k):
		count = 0
		for num in arr:
			count += num // k
			if num % k != 0:
				count += 1
		return count


class Solution:

	def totalCount(self, arr, n, k):
		x = 0
		for i in arr:
			y = i // k
			if i / k > y:
				x = x + y + 1
			else:
				x = x + y
		return x