# total arguments input() #input = "5 2 5 7 6 8 1 7 7" numbers = list(map(int, input().split())) i = 0 length = len(numbers) dictNumbers = dict() while(i < length): if(numbers[i] not in dictNumbers.keys()): dictNumbers[numbers[i]] = 0 dictNumbers[numbers[i]] += 1 i+=1 dictIndexes = dict() for key in dictNumbers: if(dictNumbers[key] not in dictIndexes): dictIndexes[dictNumbers[key]] = [key] else: dictIndexes[dictNumbers[key]].append(key) maxOccurences = max(dictIndexes.keys()) currentNumber = 0 numberOfBuckets = 0 while(currentNumber < length): for index in dictIndexes[maxOccurences]: currentNumber += maxOccurences + maxOccurences - 1 numberOfBuckets += 1 if(currentNumber >= length): break maxOccurences -= 1 print(numberOfBuckets)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | # total arguments input() #input = "5 2 5 7 6 8 1 7 7" numbers = list(map(int, input().split())) i = 0 length = len(numbers) dictNumbers = dict() while(i < length): if(numbers[i] not in dictNumbers.keys()): dictNumbers[numbers[i]] = 0 dictNumbers[numbers[i]] += 1 i+=1 dictIndexes = dict() for key in dictNumbers: if(dictNumbers[key] not in dictIndexes): dictIndexes[dictNumbers[key]] = [key] else: dictIndexes[dictNumbers[key]].append(key) maxOccurences = max(dictIndexes.keys()) currentNumber = 0 numberOfBuckets = 0 while(currentNumber < length): for index in dictIndexes[maxOccurences]: currentNumber += maxOccurences + maxOccurences - 1 numberOfBuckets += 1 if(currentNumber >= length): break maxOccurences -= 1 print(numberOfBuckets) |