s_id stringlengths 10 10 | p_id stringlengths 6 6 | u_id stringlengths 10 10 | date stringlengths 10 10 | language stringclasses 1
value | original_language stringclasses 11
values | filename_ext stringclasses 1
value | status stringclasses 1
value | cpu_time int64 0 100 | memory stringlengths 4 6 | code_size int64 15 14.7k | code stringlengths 15 14.7k | problem_id stringlengths 6 6 | problem_description stringlengths 358 9.83k | input stringlengths 2 4.87k | output stringclasses 807
values | __index_level_0__ int64 1.1k 1.22M |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s312091169 | p04031 | u753803401 | 1565710907 | Python | Python (3.4.3) | py | Accepted | 25 | 2940 | 189 | n = int(input())
a = list(map(int, input().split()))
a.sort()
c = 10 ** 9
for i in range(a[0], a[-1] + 1):
tc = 0
for j in a:
tc += (j - i) ** 2
c = min(c, tc)
print(c)
| p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,281 |
s665793367 | p04031 | u820461302 | 1565708219 | Python | Python (3.4.3) | py | Accepted | 39 | 5272 | 342 | # -*- coding: utf-8 -*-
import statistics
import math
# 文字列の入力
N= int(input())
# 数値用のリスト インプットをブランクで区切りリスト化
k = input()
l = [int(j) for j in k.split(" ")]
w = 0
# 算術平均値の取得
mean = round(statistics.mean(l))
for i in range(len(l)):
w += (l[i] - mean) ** 2
print(w) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,282 |
s633648405 | p04031 | u778700306 | 1565695159 | Python | Python (3.4.3) | py | Accepted | 28 | 3316 | 310 |
import collections
import itertools
import sys
import time
def getint(): return int(input())
def getints(): return list(map(int, input().split()))
n = getint()
xs= getints()
res = 100**2 * n
for g in range(-100,101):
tmp = 0
for x in xs:
tmp += (x-g)**2
res = min(res, tmp)
print(res) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,283 |
s855957579 | p04031 | u514894322 | 1565668159 | Python | Python (3.4.3) | py | Accepted | 23 | 3060 | 159 | n = int(input())
*l, = map(int,input().split())
ans = 10**6
for i in range(min(l),max(l)+1):
tmp = sum([(y-i)**2 for y in l])
ans = min(tmp,ans)
print(ans) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,284 |
s885483287 | p04031 | u514894322 | 1565668078 | Python | Python (3.4.3) | py | Accepted | 23 | 2940 | 152 | n = int(input())
*l, = map(int,input().split())
ans = 10**6
for i in range(-100,101):
tmp = sum([(y-i)**2 for y in l])
ans = min(tmp,ans)
print(ans) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,285 |
s458749449 | p04031 | u066455063 | 1565658917 | Python | Python (3.4.3) | py | Accepted | 26 | 3060 | 261 | N = int(input())
a = list(map(int, input().split()))
a.sort()
search = [i for i in range(a[0], a[-1]+1)]
ans = 100000
cost = [0] * len(search)
for i in range(len(search)):
for j in range(len(a)):
cost[i] += (search[i] - a[j])**2
print(min(cost))
| p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,286 |
s140682400 | p04031 | u134712256 | 1565579115 | Python | Python (3.4.3) | py | Accepted | 20 | 3188 | 137 | N = int(input())
a = list(map(int,input().split()))
ave = sum(a)/N
ave = round(ave)
sum = 0
for i in a:
sum += (i-ave)**2
print(sum)
| p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,287 |
s795220182 | p04031 | u134712256 | 1565578881 | Python | Python (3.4.3) | py | Accepted | 18 | 3060 | 222 | N = input()#str
a = list(map(int,input().split()))
N = int(N)
ave = 0.0
for i in a:
ave += i
#print("ave",ave)
ave /= N
ave = round(ave)
#print("ave",ave)
sum = 0
for i in range(N):
sum += (a[i]-ave)**2
print(sum)
| p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,288 |
s534554149 | p04031 | u874741582 | 1565556918 | Python | Python (3.4.3) | py | Accepted | 22 | 3060 | 137 | import math
n = float(input())
a = list(map(float,input().split()))
x =round(sum(a)/n)
s = 0
for i in a:
s += (x-i)**2
print(int(s))
| p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,289 |
s718368279 | p04031 | u874741582 | 1565555822 | Python | Python (3.4.3) | py | Accepted | 17 | 3060 | 136 | import math
n = float(input())
a = list(map(float,input().split()))
x =round(sum(a)/n)
s = 0
for i in a:
s += (x-i)**2
print(int(s)) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,290 |
s566591402 | p04031 | u874741582 | 1565555517 | Python | Python (3.4.3) | py | Accepted | 17 | 3060 | 136 | import math
n = float(input())
a = list(map(float,input().split()))
x =round(sum(a)/n)
s = 0
for i in a:
s += (x-i)**2
print(int(s)) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,291 |
s047167160 | p04031 | u672475305 | 1565543319 | Python | Python (3.4.3) | py | Accepted | 17 | 2940 | 149 | n = int(input())
lst = [int(i) for i in input().split()]
ave = round(sum(lst) / n)
ans = 0
for i in range(n):
ans += (lst[i] - ave)**2
print(ans) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,292 |
s512233619 | p04031 | u536377809 | 1565483695 | Python | Python (3.4.3) | py | Accepted | 24 | 3316 | 213 | n=int(input())
a=[int(x) for x in input().split()]
print(min([sum([(x-item)**2 for x in a]) for item in list(range(-100,101)
)
]
)
) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,293 |
s191415414 | p04031 | u457554982 | 1565451511 | Python | Python (3.4.3) | py | Accepted | 25 | 3060 | 180 | n=input()
kazu=list(map(int, input().split()))
kotae=9999999999
for i in range(-100,101):
kei=0
for j in kazu:
jijo=(i-j)**2
kei+=jijo
if kei<kotae:
kotae=kei
print(kotae) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,294 |
s877973464 | p04031 | u626337957 | 1565382298 | Python | Python (3.4.3) | py | Accepted | 25 | 2940 | 205 | N = int(input())
nums = list(map(int, input().split()))
min_cost = 4*100**3
for i in range(-100, 101):
cost = 0
for num in nums:
cost += (i-num)**2
min_cost = min(min_cost, cost)
print(min_cost)
| p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,295 |
s333519195 | p04031 | u280853184 | 1565296676 | Python | Python (2.7.6) | py | Accepted | 15 | 2568 | 237 | N = raw_input()
a = map(int,raw_input().split())
max_num = max(a)
min_num = min(a)
ans = []
b = 0
for i in range(min_num,max_num+1):
for j in range(0,int(N)):
b +=(a[j]-i)*(a[j]-i)
ans.append(b)
b = 0
print min(ans) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,296 |
s111228741 | p04031 | u333190709 | 1565270937 | Python | Python (3.4.3) | py | Accepted | 38 | 5332 | 804 | #!/usr/bin/env python3
import sys, math, fractions, itertools
def solve(N: int, a: "List[int]"):
s = sum(a)
k1 = math.floor(s / N)
k2 = math.ceil(s / N)
d1 = 0
d2 = 0
for i in range(N):
d1 += (a[i] - k1) ** 2
d2 += (a[i] - k2) ** 2
print(min(d1, d2))
return
# Generat... | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,297 |
s878827273 | p04031 | u084324798 | 1565240133 | Python | Python (3.4.3) | py | Accepted | 17 | 3060 | 158 | num = int(input())
A = list(map(int, input().split()))
sumA = sum(A)
obj = round(sumA/num)
ans = 0
for i in range(num):
ans += (A[i]-obj) ** 2
print(ans) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,298 |
s278115720 | p04031 | u084324798 | 1565239988 | Python | Python (3.4.3) | py | Accepted | 18 | 3188 | 188 | num = int(input())
A = list(map(int, input().split()))
sumA = sum(A)
obj = round(sumA/num)
sum2A = 0
for i in range(num):
sum2A += A[i] ** 2
print(sum2A - (2*obj*sumA) + (num*obj**2)) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,299 |
s649388961 | p04031 | u777283665 | 1565214796 | Python | Python (3.4.3) | py | Accepted | 18 | 2940 | 134 | n = int(input())
a = list(map(int,input().split()))
mean = round(sum(a) / n)
ans = 0
for i in a:
ans += (i-mean) ** 2
print(ans) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,300 |
s982940701 | p04031 | u278463847 | 1565166094 | Python | Python (3.4.3) | py | Accepted | 26 | 3060 | 187 | n = int(input())
a = list(map(int, input().split()))
l = []
for y in range(-100, 101):
cost = 0
for i in range(n):
cost += (a[i] - y) ** 2
l.append(cost)
print(min(l)) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,301 |
s064122880 | p04031 | u578850957 | 1565146128 | Python | Python (3.4.3) | py | Accepted | 28 | 3064 | 315 | N = int(input())
a_list = list(map(int,input().split()))
min_sum = 100000000
temp_sum = 0
ans = 0
for i in range(-100,101):
for j in range(N):
temp_sum += pow(i-a_list[j],2)
if j==N-1:
if temp_sum < min_sum:
min_sum = temp_sum
temp_sum = 0
print(min_sum) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,302 |
s631906650 | p04031 | u999669171 | 1565067674 | Python | Python (3.4.3) | py | Accepted | 20 | 3060 | 221 | N = int( input() )
numbers = list(map( int, input().split() ) )
ave = sum(numbers) / N
#print( ave )
ave_int = round( ave )
#print( ave_int )
ans = 0
for number in numbers :
ans += (number - ave_int ) **2
print( ans ) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,303 |
s082096806 | p04031 | u957872856 | 1565016308 | Python | Python (3.4.3) | py | Accepted | 25 | 3064 | 177 | n = int(input())
arr = list(map(int,input().split()))
s = []
for i in range(min(arr), max(arr)+1):
cost = 0
for j in arr:
cost += (j-i)**2
s.append(cost)
print(min(s)) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,304 |
s554868999 | p04031 | u921773161 | 1564943307 | Python | Python (3.4.3) | py | Accepted | 25 | 3060 | 213 | N = int(input())
a = list(map(int, input().split()))
ans_lsit = []
for i in range(-100, 101):
tmp = 0
for j in range(N):
tmp += (i-a[j])**2
ans_lsit.append(tmp)
ans = min(ans_lsit)
print(ans) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,305 |
s298368878 | p04031 | u200785298 | 1564884274 | Python | Python (3.4.3) | py | Accepted | 23 | 3064 | 639 | #!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)
def solve(N: int, a: "List[int]"):
ret = float('inf')
mn = min(a)
mx = max(a)
for v in range(mn, mx + 1):
tmp = 0
for x in a:
tmp += (x - v) ** 2
ret = min(ret, tmp)
print(ret)
return
def main... | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,306 |
s726791268 | p04031 | u844646164 | 1564857643 | Python | Python (3.4.3) | py | Accepted | 20 | 3064 | 252 | import math
n = int(input())
a = list(map(int, input().split()))
ave = sum(a)/n
s_ave = math.ceil(ave)
l_ave = math.floor(ave)
s_cost = 0
l_cost = 0
for i in range(n):
s_cost += (a[i]-s_ave)**2
l_cost += (a[i]-l_ave)**2
print(min(s_cost, l_cost)) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,307 |
s970305557 | p04031 | u687044304 | 1564662301 | Python | Python (3.4.3) | py | Accepted | 23 | 2940 | 385 | # -*- coding:utf-8 -*-
def solve():
N = int(input())
A = list(map(int, input().split()))
# 全探索余裕
ans = float("inf")
for i in range(-100, 100+1):
cost = 0
for j in range(N):
# 全てiに書き換える
cost += (i - A[j])**2
ans = min(ans, cost)
print(ans)
... | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,308 |
s788064909 | p04031 | u118211443 | 1564662184 | Python | Python (3.4.3) | py | Accepted | 17 | 2940 | 140 | n = int(input())
a = list(map(int, input().split()))
d = round(sum(a) / len(a))
cost = 0
for i in a:
cost += (i - d) ** 2
print(cost)
| p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,309 |
s836289263 | p04031 | u677523557 | 1564543024 | Python | Python (3.4.3) | py | Accepted | 26 | 3060 | 183 | N = int(input())
A = list(map(int, input().split()))
ans = 200**2*1000
for k in range(-100, 101):
l = 0
for a in A:
l += abs(a-k)**2
ans = min(ans, l)
print(ans) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,310 |
s769182749 | p04031 | u576712004 | 1564458416 | Python | Python (3.4.3) | py | Accepted | 25 | 2940 | 185 | N = input()
a = list(map(int, input().split()))
ans = 10 ** 10
for y in range(-100, 101):
cost = 0
for x in a:
cost += (x - y) ** 2
ans = min(ans, cost)
print(ans)
| p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,311 |
s422850756 | p04031 | u408620326 | 1564023937 | Python | Python (3.4.3) | py | Accepted | 23 | 2940 | 145 | N=int(input())
An=[int(x) for x in input().split()]
ans=(200**2)*N
for i in range(-100,101):
ans=min(ans,sum([(a-i)**2 for a in An]))
print(ans) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,312 |
s747285193 | p04031 | u201660334 | 1564002964 | Python | Python (3.4.3) | py | Accepted | 25 | 3060 | 205 | n = int(input())
a = list(map(int, input().split()))
cost = []
for i in range(min(a), max(a) + 1):
temp = 0
for j in range(n):
temp += (a[j] - i) ** 2
cost.append(temp)
print(min(cost)) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,313 |
s513620409 | p04031 | u800258529 | 1563591895 | Python | Python (3.4.3) | py | Accepted | 25 | 3060 | 130 | n=int(input())
a=list(map(int,input().split()))
print(min([sum([(a[j]-i)**2 for j in range(n)]) for i in range(min(a),max(a)+1)])) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,314 |
s380069344 | p04031 | u366959492 | 1563550678 | Python | Python (3.4.3) | py | Accepted | 25 | 2940 | 164 | n=int(input())
a=list(map(int,input().split()))
l=[]
for x in range(-100,101):
c=0
for i in range(n):
c+=(a[i]-x)**2
l.append(c)
print(min(l))
| p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,315 |
s770735293 | p04031 | u828766688 | 1563501497 | Python | Python (3.4.3) | py | Accepted | 24 | 2940 | 211 |
N = int(input())
A = list(map(int,input().split()))
ans = float("inf")
for i in range(201):
i -= 100
now = 0
for a in A:
now += ( a - i ) ** 2
ans = min (ans,now)
print (ans)
| p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,316 |
s660995527 | p04031 | u537782349 | 1563324175 | Python | Python (3.4.3) | py | Accepted | 25 | 3060 | 210 | a = int(input())
b = list(map(int, input().split()))
b.sort()
c = []
for i in range(b[0], b[len(b)-1] + 1):
d = 0
for j in range(len(b)):
d += (b[j] - i)**2
c.append(d)
c.sort()
print(c[0])
| p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,317 |
s937015112 | p04031 | u103341055 | 1563309572 | Python | Python (3.4.3) | py | Accepted | 26 | 2940 | 264 | N = int(input())
A = [int(n) for n in input().split()]
min = 100*(200)**2+10
for n in range(-100,101):
tmp = 0
for a in A:
if a == n:
pass
else:
tmp += (a - n)**2
if min > tmp:
min = tmp
print(min)
| p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,318 |
s157823749 | p04031 | u223133214 | 1563258818 | Python | Python (3.4.3) | py | Accepted | 25 | 3060 | 263 | import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
big = max(A)
sml = min(A)
ans = float('inf')
for i in range(sml, big + 1):
cnt = 0
for a in A:
cnt += (abs(i - a))**2
ans = min(ans, cnt)
print(ans)
| p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,319 |
s487853825 | p04031 | u191874006 | 1563129431 | Python | Python (3.4.3) | py | Accepted | 25 | 2940 | 229 | #!/usr/bin/env python3
#ABC43 C
n = int(input())
a = list(map(int,input().split()))
mi = float('inf')
for i in range(-100,101):
cost = 0
for j in range(n):
cost += (i - a[j])**2
mi = min(mi,cost)
print(mi)
| p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,320 |
s754572892 | p04031 | u334260611 | 1563125859 | Python | Python (3.4.3) | py | Accepted | 25 | 3060 | 291 | N = int(input())
a = list(map(int, input().split(' ')))
#print(N)
#print(a)
min_a = min(a)
max_a = max(a)
min_cost = 10000 * 100
for num in range(min_a, max_a + 1):
cost = 0
for z in a:
cost += (z - num) ** 2
if min_cost > cost:
min_cost = cost
print(min_cost) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,321 |
s949383322 | p04031 | u567434159 | 1562899082 | Python | Python (3.4.3) | py | Accepted | 32 | 2940 | 190 | _ = input()
a = list(map(int, input().split()))
ans = 10 ** 18
for val in range(-200, 200):
curr = 0
for it in a:
curr += (it - val) ** 2
ans = min(ans, curr)
print(ans)
| p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,322 |
s678531840 | p04031 | u875291233 | 1562534625 | Python | Python (3.4.3) | py | Accepted | 18 | 3060 | 322 | # coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意
n = int(input())
a = [int(i) for i in readline().split()]
m = sum(a)//n
ans = 100000000
for i in {-1,0,1}:
res = sum((x-m-i)**2 for x in a)
ans = min(ans,res)
print(ans)
| p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,323 |
s316529205 | p04031 | u820047642 | 1562525369 | Python | Python (3.4.3) | py | Accepted | 25 | 3060 | 167 | N=int(input())
A=list(map(int,input().split()))
ans=10**9+7
for i in range(201):
memo=0
for j in A:
memo+=(i+j-100)**2
ans=min(ans,memo)
print(ans) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,324 |
s957926315 | p04031 | u787456042 | 1562469854 | Python | Python (3.4.3) | py | Accepted | 53 | 5636 | 233 | from math import floor, ceil
from statistics import mean
n = int(input())
a = list(map(int, input().split()))
mc = ceil(mean(a))
mf = floor(mean(a))
dc = sum([(i-mc)**2 for i in a])
df = sum([(i-mf)**2 for i in a])
print(min(dc, df)) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,325 |
s553455366 | p04031 | u665038048 | 1562446069 | Python | Python (3.4.3) | py | Accepted | 26 | 3060 | 288 | n = int(input())
a = list(map(int, input().split()))
nijo_list = []
for i in range(min(a), max(a)):
nijo_sum = 0
for j in range(len(a)):
nijo = (a[j] - i)**2
nijo_sum += nijo
nijo_list.append(nijo_sum)
if nijo_list:
print(min(nijo_list))
else:
print(0) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,326 |
s410538783 | p04031 | u537976628 | 1562038549 | Python | Python (3.4.3) | py | Accepted | 17 | 3060 | 229 | N = int(input())
A = list(map(int, input().split()))
ttl1, ttl2, ttl3 = 0, 0, 0
avarage1 = -(-sum(A) // N)
avarage2 = sum(A) // N
for i in A:
ttl1 += (i - avarage1) ** 2
ttl2 += (i - avarage2) ** 2
print(min(ttl1, ttl2))
| p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,327 |
s632991432 | p04031 | u537976628 | 1562038218 | Python | Python (3.4.3) | py | Accepted | 17 | 3064 | 296 | N = int(input())
A = list(map(int, input().split()))
ttl1, ttl2, ttl3 = 0, 0, 0
avarage1 = -(-sum(A) // N)
avarage2 = sum(A) // N
avarage3 = round(sum(A) / N)
for i in A:
ttl1 += (i - avarage1) ** 2
ttl2 += (i - avarage2) ** 2
ttl3 += (i - avarage3) ** 2
print(min(ttl1, ttl2, ttl3))
| p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,328 |
s836656615 | p04031 | u375823148 | 1562007274 | Python | Python (3.4.3) | py | Accepted | 25 | 2940 | 175 | n = int(input())
a = list(map(int, input().split()))
r = []
for i in range(-100, 101):
sum = 0
for j in range(n):
sum += (a[j]-i)**2
r.append(sum)
r.sort()
print(r[0])
| p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,329 |
s022316747 | p04031 | u970449052 | 1561840444 | Python | Python (3.4.3) | py | Accepted | 23 | 3316 | 173 | n=int(input())
al=list(map(int,input().split()))
def fn(m):
rtn=0
for a in al:
rtn+=(a-m)**2
return rtn
mean=sum(al)//n
print(min(fn(mean),fn(mean+1))) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,330 |
s606744642 | p04031 | u196697332 | 1561826830 | Python | Python (3.4.3) | py | Accepted | 17 | 3064 | 275 | import math
N = int(input())
a = [int(_) for _ in input().split()]
floor = math.floor(sum(a) / len(a))
ceil = math.ceil(sum(a) / len(a))
ceil_sum = sum([(item - ceil) ** 2 for item in a])
floor_sum = sum([(item - floor) ** 2 for item in a])
print(min(ceil_sum, floor_sum)) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,331 |
s963345499 | p04031 | u293523199 | 1561703692 | Python | Python (3.4.3) | py | Accepted | 22 | 3060 | 284 | N = int(input())
A = list(map(int, input().split()))
total_costs = {}
if( len(set(A)) == 1 ):
print(0)
else:
for i in range(-100, 101):
cost = 0
for a in A:
cost += (a - i)*(a - i)
total_costs[i] = cost
print(min(total_costs.values())) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,332 |
s364306197 | p04031 | u293523199 | 1561703650 | Python | Python (3.4.3) | py | Accepted | 25 | 3064 | 279 | N = int(input())
A = list(map(int, input().split()))
total_costs = {}
if( len(set(A)) == 1 ):
print(0)
else:
for i in range(-100, 101):
cost = 0
for a in A:
cost += (a - i)**2
total_costs[i] = cost
print(min(total_costs.values())) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,333 |
s891657694 | p04031 | u243699903 | 1561689773 | Python | Python (3.4.3) | py | Accepted | 17 | 2940 | 141 | n=int(input())
a_list=[int(i) for i in input().split()]
center=round(sum(a_list)/n)
ans=0
for a in a_list:
ans+=(a-center)**2
print(ans) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,334 |
s971352377 | p04031 | u223646582 | 1561671270 | Python | Python (3.4.3) | py | Accepted | 25 | 2940 | 171 | N=int(input())
a=[int(i) for i in input().split()]
ans=10**7
for i in range(min(a),max(a)+1):
c=0
for j in a:
c+=(j-i)**2
ans=min(ans,c)
print(ans)
| p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,335 |
s061714035 | p04031 | u911575040 | 1561659644 | Python | Python (3.4.3) | py | Accepted | 25 | 3060 | 176 | n=int(input())
a=list(map(int,input().split()))
ans=[]
an=0
for i in range(-100,101):
for j in range(n):
an+=(i-a[j])**2
ans.append(an)
an=0
print(min(ans)) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,336 |
s600934153 | p04031 | u921194336 | 1561530379 | Python | Python (3.4.3) | py | Accepted | 27 | 3060 | 220 | n = int(input())
a = list(map(int, input().split()))
s = 0
s_pre = 10000000000
for j in range(-100, 101):
for i in range(n):
s += pow((a[i] - j),2)
if s_pre > s:
s_pre = s
s = 0
print(s_pre) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,337 |
s254562103 | p04031 | u263830634 | 1561400723 | Python | Python (3.4.3) | py | Accepted | 24 | 3060 | 188 | N = int(input())
a = list(map(int, input().split()))
ans = 10000 ** 100
for i in range(-100, 101):
tmp = 0
for j in a:
tmp += (j-i)**2
ans = min(ans, tmp)
print (ans) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,338 |
s569250288 | p04031 | u298297089 | 1561282387 | Python | Python (3.4.3) | py | Accepted | 26 | 3060 | 185 | N = int(input())
A = list(map(int, input().split()))
mn = 10**9
for j in range(min(A), max(A)+1):
cost = 0
for i in range(N):
cost += (A[i]-j)**2
mn = min(cost, mn)
print(mn) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,339 |
s516462102 | p04031 | u726615467 | 1561251320 | Python | Python (3.4.3) | py | Accepted | 26 | 3316 | 296 | # encoding: utf-8
import sys
# input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
ans = 10 ** 9 + 7
for i in range(min(a), max(a) + 1):
ans_tmp = 0
for j, aj in enumerate(a):
ans_tmp += (i - a[j]) ** 2
if ans > ans_tmp: ans = ans_tmp
print(ans) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,340 |
s431810136 | p04031 | u607865971 | 1561248731 | Python | Python (3.4.3) | py | Accepted | 31 | 3772 | 614 | import sys
from collections import Counter, deque, defaultdict
from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
from functools import reduce
from math import ceil, floor, log10, log2, factorial
from pprint import pprint
sys.setrecursionlimit(1000000)
# MOD = 10 ** 9 + 7
# N = in... | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,341 |
s820975332 | p04031 | u323120917 | 1561248296 | Python | Python (3.4.3) | py | Accepted | 32 | 3060 | 188 | n=int(input())
l=[]
p=input().rstrip().split(' ')
for i in range(-100,101):
s=0;
for j in range(0,len(p)):
t=(int(p[j])-i)**2;
s=s+t;
l.append(s)
print(min(l))
| p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,342 |
s231262580 | p04031 | u059210959 | 1561169444 | Python | Python (3.4.3) | py | Accepted | 48 | 5460 | 897 | # encoding:utf-8
import copy
import random
import bisect #bisect_left これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in... | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,343 |
s444729271 | p04031 | u494927057 | 1561124344 | Python | Python (3.4.3) | py | Accepted | 19 | 2940 | 163 | N = int(input())
a = list(map(int, input().split()))
mean = int(round(sum(a) / len(a)))
ans = 0
for i in range(len(a)):
ans += (a[i] - mean) ** 2
print(ans)
| p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,344 |
s345562926 | p04031 | u494927057 | 1561123303 | Python | Python (3.4.3) | py | Accepted | 23 | 2940 | 303 | N = int(input())
a = list(map(int, input().split()))
def get_cost(now, target):
return (now - target) * (now - target)
ans = 10000000
for i in range(min(a), max(a) + 1):
cost_sum = 0
for j in a:
cost_sum += get_cost(j, i)
if cost_sum < ans:
ans = cost_sum
print(ans)
| p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,345 |
s295410293 | p04031 | u928784113 | 1561088689 | Python | Python (3.4.3) | py | Accepted | 17 | 3064 | 200 | N = int(input())
a = list(map(int,input().split()))
av = sum(a)//N
ans1 = []
ans2 = []
for i in range(N):
ans1.append((a[i]-av)**2)
ans2.append((a[i]-av-1)**2)
print(min(sum(ans1),sum(ans2))) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,346 |
s041545372 | p04031 | u305781333 | 1561064849 | Python | Python (3.4.3) | py | Accepted | 24 | 3064 | 195 | N = int(input())
a = [int(i) for i in input().split()]
answer = 10**10
for i in range(min(a), max(a)+1):
cost = 0
for j in a:
cost += (i-j)**2
answer = min(answer, cost)
print(answer) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,347 |
s364445663 | p04031 | u722535636 | 1561061023 | Python | Python (3.4.3) | py | Accepted | 23 | 3060 | 152 | n=int(input())
l=list(map(int,input().split()))
s=sum(l)
ans=10**7
for i in range(min(l),max(l)+1):
ans=min(ans, sum([(x-i)**2 for x in l]))
print(ans) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,348 |
s246012178 | p04031 | u457423258 | 1561059511 | Python | Python (3.4.3) | py | Accepted | 17 | 2940 | 113 | N=int(input())
A=list(map(int,input().split()))
E=round(sum(A)/N)
ans=0
for a in A:
ans+=(E-a)**2
print(ans) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,349 |
s899134833 | p04031 | u136811344 | 1561050429 | Python | Python (3.4.3) | py | Accepted | 18 | 2940 | 115 | N = int(input())
A = list(map(int, input().split()))
avr = round(sum(A)/len(A))
print(sum([(a-avr)**2 for a in A])) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,350 |
s416584519 | p04031 | u762557532 | 1560930487 | Python | Python (3.4.3) | py | Accepted | 25 | 3060 | 196 | N = int(input())
A = list(map(int,input().split()))
solver = []
for M in range(-100,100+1):
cost = 0
for i in range(N):
cost += (A[i] - M) ** 2
solver.append(cost)
print(min(solver)) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,351 |
s713988744 | p04031 | u775266130 | 1560915071 | Python | Python (3.4.3) | py | Accepted | 25 | 3060 | 214 | from math import ceil
n = int(input())
num = list(map(int, input().split()))
sol = 10 ** 15
for i in range(-100, 101):
tmp = 0
for j in range(n):
tmp += (num[j] - i) ** 2
sol = min(sol, tmp)
print(int(sol)) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,352 |
s248591572 | p04031 | u247769252 | 1560783677 | Python | Python (3.4.3) | py | Accepted | 23 | 3060 | 391 | import sys
N = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))
min_val = -100
for i in range(-100, 101):
sum_calc = 0
for j in range(N):
sum_calc += (a[j] - i)*(a[j] - i)
if i == -100:
min_val = i
min_sum_calc = sum_calc
if min_sum_calc > sum_calc:
... | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,353 |
s450556123 | p04031 | u671455949 | 1560733066 | Python | Python (3.4.3) | py | Accepted | 20 | 3316 | 206 | n = int(input())
a = list(map(int, input().split()))
x_1 = sum(a) // n
x_2 = x_1 + 1
cost_1 = 0
cost_2 = 0
for _a in a:
cost_1 += (x_1 - _a) ** 2
cost_2 += (x_2 - _a) ** 2
print(min(cost_1, cost_2)) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,354 |
s335723379 | p04031 | u114648678 | 1560337006 | Python | Python (3.4.3) | py | Accepted | 25 | 3064 | 180 | n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=1000000000
s=[]
for j in range(a[0],a[-1]+1):
k=0
for i in range(n):
k+=(a[i]-j)**2
s.append(k)
print(min(s)) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,355 |
s211567222 | p04031 | u474423089 | 1560309119 | Python | Python (3.4.3) | py | Accepted | 22 | 3064 | 311 | def main():
n = int(input())
a = list(map(int,input().split(' ')))
cost = 100**2*100
for i in range(-100,101):
tmp = 0
for j in a:
if tmp >= cost:
break
tmp += (j-i)**2
if cost > tmp:
cost = tmp
print(cost)
main() | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,356 |
s055038543 | p04031 | u112318601 | 1560260632 | Python | Python (3.4.3) | py | Accepted | 17 | 3060 | 202 | n = int(input())
a = list(map(int, input().split()))
_mean1 = sum(a)//n
_mean2 = _mean1+1
_sum1=0
_sum2=0
for i in a:
_sum1+=(i - _mean1)**2
_sum2+=(i-_mean2)**2
print(min(_sum1, _sum2)) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,357 |
s490675781 | p04031 | u077291787 | 1560240482 | Python | Python (3.4.3) | py | Accepted | 24 | 3060 | 284 | # ARC059C - いっしょ / Be Together (ABC043C)
n = int(input())
lst = list(map(int, input().rstrip().split()))
ans = float("inf")
MIN, MAX = min(lst), max(lst)
for i in range(MIN, MAX + 1):
cnt = 0
for j in lst:
cnt += (i - j) ** 2
ans = min(ans, cnt)
print(ans) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,358 |
s389391106 | p04031 | u704001626 | 1560221788 | Python | Python (3.4.3) | py | Accepted | 24 | 3060 | 267 | # -*- coding: utf-8 -*-
n = int(input())
a = list(map(int,input().split()))
#最小値と最大値の間の値になる。
min_a = min(a)
max_a = max(a)
cost = []
i = min_a
while i <= max_a:
cost.append(sum(map(lambda x:(x-i)**2,a)))
i+=1
print(min(cost))
| p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,359 |
s973409876 | p04031 | u844005364 | 1560216659 | Python | Python (3.4.3) | py | Accepted | 18 | 2940 | 118 | n = int(input())
arr = list(map(int, input().split()))
x = round(sum(arr) / n)
print(sum((x - i)**2 for i in arr))
| p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,360 |
s061618761 | p04031 | u187205913 | 1560085958 | Python | Python (3.4.3) | py | Accepted | 24 | 3064 | 205 | n = int(input())
a = list(map(int,input().split()))
mx, mn = max(a), min(a)
ans = float('inf')
for i in range(mn,mx+1):
ret = 0
for j in a:
ret += (j-i)**2
ans = min(ans,ret)
print(ans) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,361 |
s196514867 | p04031 | u734548018 | 1560046868 | Python | Python (3.4.3) | py | Accepted | 57 | 5844 | 271 | #!/usr/bin/python3
# -*- coding: utf-8 -*-
import math
from decimal import Decimal as dec
N = int(input())
An = list(map(int, input().split()))
x = math.floor(dec(sum(An))/dec(N))
cost = [0,0]
for a in An:
cost[0] += (x-a)**2
cost[1] += (x+1-a)**2
print(min(cost)) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,362 |
s093415499 | p04031 | u933214067 | 1560035404 | Python | Python (3.4.3) | py | Accepted | 60 | 5972 | 1,539 | import math
import fractions
import copy
#以下てんぷら
def j(q):
if q==1: print("YES")
elif q == 0:print("NO")
exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
if (x>y):print("+")
elif (x<y): print("-")
else: print("?")
"""
def ip():
return int(input())
def printrow(a):
for i in a:
print(i)... | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,363 |
s299757250 | p04031 | u941753895 | 1560028636 | Python | Python (3.4.3) | py | Accepted | 67 | 6816 | 434 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()
def main():
n=I()
l=LI()
mn=inf
f... | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,364 |
s561567514 | p04031 | u745561510 | 1560018424 | Python | Python (3.4.3) | py | Accepted | 17 | 3064 | 241 | N = int(input())
a = list(map(int, input().split()))
med_a = sum(a) / N
candidate = [int(med_a), int(med_a + 0.9)]
cost = [0, 0]
for i in a:
for j in range(len(candidate)):
cost[j] += (i - candidate[j]) ** 2
print(min(cost)) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,365 |
s221756978 | p04031 | u518042385 | 1559877653 | Python | Python (3.4.3) | py | Accepted | 25 | 2940 | 153 | n=int(input())
l=list(map(int,input().split()))
c=1000000
for i in range(-100,101):
c1=0
for j in l:
c1+=(j-i)**2
if c>c1:
c=c1
print(c)
| p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,366 |
s835193218 | p04031 | u365364616 | 1559851755 | Python | Python (3.4.3) | py | Accepted | 17 | 2940 | 183 | n = int(input())
a = list(map(int, input().split()))
s = sum(a)
if s % n * 2 < n:
x = s // n
else:
x = (s + n - 1) // n
ans = 0
for i in a:
ans += (x - i) ** 2
print(ans)
| p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,367 |
s429293649 | p04031 | u399721252 | 1559668837 | Python | Python (3.4.3) | py | Accepted | 18 | 3064 | 306 | n = int(input())
num_list = [ int(v) for v in input().split() ]
min_num, max_num = min(num_list), max(num_list)
sum_num = sum(num_list)
square_sum_num = sum([ v**2 for v in num_list ])
ans = square_sum_num
for i in range(min_num,max_num+1):
ans = min(ans, square_sum_num-2*i*sum_num+n*i**2)
print(ans) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,368 |
s682603771 | p04031 | u374531474 | 1559616951 | Python | Python (3.4.3) | py | Accepted | 24 | 3060 | 216 | N = int(input())
a = list(map(int, input().split()))
min_cost = 10 ** 7
for y in range(-100, 101):
cost = sum([(a[i] - y) ** 2 for i in range(N)])
if cost < min_cost:
min_cost = cost
print(min_cost)
| p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,369 |
s842424737 | p04031 | u691018832 | 1559451844 | Python | Python (3.4.3) | py | Accepted | 17 | 3060 | 208 | # sys.stdin.readline()
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
match = round(sum(a)/n)
ans = 0
for i in range(n):
ans += (a[i]-match)**2
print(int(ans)) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,370 |
s055935500 | p04031 | u057109575 | 1559413811 | Python | Python (3.4.3) | py | Accepted | 18 | 3188 | 102 | N, *a = map(int, open(0).read().split())
tgt = round(sum(a) / N)
print(sum((v - tgt) ** 2 for v in a)) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,371 |
s237217274 | p04031 | u551909378 | 1559197290 | Python | Python (3.4.3) | py | Accepted | 25 | 3064 | 298 | N = int(input())
a = [int(x) for x in input().split()]
amin, amax = min(a), max(a)
temp = [ai - amin for ai in a]
ans = sum([ai**2 for ai in temp])
for A in range(amin,amax+1):
for i in range(N): temp[i] -= 1
nans = sum([ai**2 for ai in temp])
if ans > nans: ans = nans
print(ans)
| p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,372 |
s292117586 | p04031 | u802772880 | 1559190755 | Python | Python (3.4.3) | py | Accepted | 17 | 3060 | 201 | n=int(input())
a=list(map(int,input().split()))
ans=0
def f(x):
b=0
for i in a:
b+=(x-i)**2
return b
if sum(a)%n==0:
ans=f(sum(a)//n)
else:
ans=f(round(sum(a)/n))
print(ans) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,373 |
s602738524 | p04031 | u728566015 | 1559183134 | Python | Python (3.4.3) | py | Accepted | 24 | 3060 | 211 | N = int(input())
a = sorted(list(map(int, input().split())))
cost = []
total = 0
for i in range(a[0], a[-1] + 1):
for x in a:
total += (x - i)**2
cost.append(total)
total = 0
print(min(cost)) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,374 |
s392273358 | p04031 | u766684188 | 1559157890 | Python | Python (3.4.3) | py | Accepted | 17 | 3060 | 131 | n=int(input())
A=tuple(map(int,input().split()))
s=sum(A)
ave=s/n
m=s//n
if m+1-ave<ave-m:
m+=1
print(sum((a-m)**2 for a in A)) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,375 |
s885667832 | p04031 | u449473917 | 1559139343 | Python | Python (3.4.3) | py | Accepted | 25 | 3060 | 180 | a=int(input())
b=list(map(int,input().split()))
cost=9999999
for i in range(min(b),max(b)+1):
c=0
for j in b:
c=c+(i-j)**2
if c<cost:
cost=c
print(cost) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,376 |
s762273817 | p04031 | u729133443 | 1559031758 | Python | Python (3.4.3) | py | Accepted | 24 | 2940 | 93 | n,a=open(0);*a,=map(int,a.split());print(min(sum((i-j-100)**2for j in a)for i in range(201))) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,377 |
s507476121 | p04031 | u008489560 | 1558640816 | Python | Python (3.4.3) | py | Accepted | 24 | 3060 | 120 | input()
l = list(map(int, input().split(' ')))
print(min([sum([(j-i)**2 for j in l]) for i in range(min(l), max(l)+1)])) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,378 |
s686480754 | p04031 | u133886644 | 1558583668 | Python | Python (3.4.3) | py | Accepted | 26 | 3064 | 243 | import sys
import bisect
input = sys.stdin.readline
N = int(input())
L = [int(v) for v in input().split()]
ans = 10 ** 18
for i in range(-100, 101):
t = 0
for v in L:
t += (v - i) ** 2
ans = min(ans, t)
print(ans) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,379 |
s030192975 | p04031 | u570545890 | 1558385847 | Python | Python (3.4.3) | py | Accepted | 17 | 2940 | 104 | n=int(input())
a=list(map(int,input().split()))
ave=round(sum(a)/n)
print(sum(abs(i-ave)**2 for i in a)) | p04031 | <span class="lang-en">
<p>Score : <var>200</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p>
<p>He may transform each integer at most ... | 2
4 8
| 8
| 1,207,380 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.