BOJ - 17392 - 우울한 방학
Updated:
import sys
def cal(N):
sad = 1
ret = 0
while sad <= N:
ret += sad * sad
sad += 1
return ret
def solution():
N, M = map(int, sys.stdin.readline().split())
arr = list(map(int, sys.stdin.readline().split()))
sadTotal = M - N - sum(arr)
total = sadTotal // (N + 1)
div = sadTotal % (N + 1)
print(
cal(total) * (N + 1 - div) + cal(total + 1) * div
)
solution()
https://www.acmicpc.net/problem/17392
Leave a comment