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
s746820736
p04025
u848647227
1543894064
Python
Python (3.4.3)
py
Accepted
25
3060
195
a = int(input()) ar = list(map(int,input().split(" "))) br = [] for i in range(min(ar),max(ar)+1): count = 0 for r in ar: count += (i - r) ** 2 br.append(count) print(min(br))
p04025
<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,201,371
s326927494
p04025
u803848678
1543603844
Python
Python (3.4.3)
py
Accepted
18
2940
145
n = int(input()) a = list(map(int, input().split())) s = sum(a) ave_new = round(s/n) ans = 0 for i in a: ans += (i-ave_new)**2 print(ans)
p04025
<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,201,372
s325089943
p04025
u844789719
1543426849
Python
Python (3.4.3)
py
Accepted
23
2940
132
N = int(input()) A = [int(_) for _ in input().split()] ans = 0 print(min([sum([(a - i)**2 for a in A]) for i in range(-100, 101)]))
p04025
<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,201,373
s166178472
p04025
u047535298
1542806965
Python
Python (3.4.3)
py
Accepted
17
3064
268
N = int(input()) a = list(map(int, input().split())) ave1 = int(sum(a)/N+0.5) ave2 = ave1-1 ave3 = ave1+1 ans1, ans2, ans3 = 0, 0, 0 for i in range(N): ans1 += (ave1 - a[i])**2 ans2 += (ave2 - a[i])**2 ans3 += (ave3 - a[i])**2 print(min(ans1, ans2, ans3))
p04025
<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,201,374
s535261443
p04025
u879870653
1541679778
Python
Python (3.4.3)
py
Accepted
26
3060
209
N = int(input()) A = list(map(int,input().split())) A = sorted(A) ANS = [] for i in range(A[0],A[-1]+1) : p = 0 for j in range(N) : p += (i-A[j])**2 ANS.append(p) ans = min(ANS) print(ans)
p04025
<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,201,375
s062214179
p04025
u603234915
1539745210
Python
Python (3.4.3)
py
Accepted
23
3188
318
def main(): N = int(input()) l = list(map(int, input().split())) ans = 10000000 min_l = min(l) max_l = max(l) for y in range(min_l, max_l+1): temp = 0 for x in l: temp += (x - y) ** 2 ans = min(ans, temp) print(ans) if __name__ == '__main__': main()
p04025
<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,201,376
s450451586
p04025
u603234915
1539745037
Python
Python (3.4.3)
py
Accepted
25
3064
356
def abss(x, y): return abs(x-y)**2 def main(): N = int(input()) l = list(map(int, input().split())) ans = 10000000 min_l = min(l) max_l = max(l) for y in range(min_l, max_l+1): temp = 0 for x in l: temp += abss(x, y) ans = min(ans, temp) print(ans) i...
p04025
<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,201,377
s616273269
p04025
u177398299
1539714687
Python
Python (3.4.3)
py
Accepted
23
3060
153
N = int(input()) a = list(map(int, input().split())) ans = 10 ** 9 for y in range(-100, 101): ans = min(ans, sum((x - y) ** 2 for x in a)) print(ans)
p04025
<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,201,378
s911539579
p04025
u099918199
1538203446
Python
Python (3.4.3)
py
Accepted
17
3060
289
n = int(input()) list_a = list((map(int, input().split()))) sum = 0 for number in list_a: sum += number ave = sum/n if ave - int(ave) <= int(ave) + 1 - ave: ave = int(ave) else: ave = int(ave) + 1 ans = 0 for number in list_a: ans += (number - ave)**2 print(int(ans))
p04025
<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,201,379
s702340429
p04025
u102126195
1538165590
Python
Python (3.4.3)
py
Accepted
27
2940
218
N = int(input()) a = list(map(int, input().split())) sum_list = [] k = 0 for i in range(-100, 101): sum_list.append(0) for j in range(N): sum_list[k] += pow(i - a[j], 2) k += 1 print(min(sum_list))
p04025
<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,201,380
s669086441
p04025
u177040005
1537373751
Python
Python (3.4.3)
py
Accepted
23
3060
251
def cost(x,y): return (x-y)*(x-y) N = int(input()) A = list(map(int, input().split())) ans = 1000000000 tmp = 0 for i in range(min(A),max(A)+1): tmp = 0 for a in A: tmp += cost(a,i) if ans > tmp: ans = tmp print(ans)
p04025
<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,201,381
s446342023
p04025
u536113865
1535916001
Python
Python (3.4.3)
py
Accepted
23
3060
171
n = int(input()) a = list(map(int,input().split())) ans = float('inf') for i in range(min(a),max(a)+1): l = [(i-k)**2 for k in a] ans = min(ans,sum(l)) print(ans)
p04025
<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,201,382
s903887111
p04025
u297574184
1533782070
Python
Python (3.4.3)
py
Accepted
17
2940
178
from math import floor N = int(input()) As = list(map(int, input().split())) aveA = sum(As) / N x = floor(aveA + 0.5) ans = 0 for A in As: ans += (A - x) ** 2 print(ans)
p04025
<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,201,383
s567313683
p04025
u297574184
1533781800
Python
Python (3.4.3)
py
Accepted
17
3060
178
from math import floor N = int(input()) As = list(map(int, input().split())) aveA = sum(As) / N x = floor(aveA + 0.5) ans = 0 for A in As: ans += (A - x) ** 2 print(ans)
p04025
<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,201,384
s210270988
p04025
u832039789
1532841426
Python
Python (3.4.3)
py
Accepted
24
2940
186
n=int(input()) res = float('inf') a=list(map(int,input().split())) for i in range(min(a),max(a)+1): tmp = 0 for j in a: tmp += (i-j)**2 res = min(res,tmp) print(res)
p04025
<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,201,385
s926182688
p04025
u200239931
1531881950
Python
Python (3.4.3)
py
Accepted
18
3064
754
import math def getinputdata(): # 配列初期化 array_result = [] data = input() array_result.append(data.split(" ")) flg = 1 try: while flg: data = input() if(data != ""): array_result.append(data.split(" ")) ...
p04025
<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,201,386
s324112968
p04025
u384679440
1531609612
Python
Python (3.4.3)
py
Accepted
27
3060
192
N = int(input()) a = list(map(int, input().split())) ans = pow(100, 9) for i in range(-100, 101): temp = 0 for j in range(len(a)): temp += pow(i - a[j], 2) ans = min(ans, temp) print(ans)
p04025
<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,201,387
s756570416
p04025
u627417051
1531438826
Python
Python (3.4.3)
py
Accepted
18
3060
199
N = int(input()) a = list(map(int, input().split())) z = sum(a) / N if z - z // 1 >= z // 1 + 1 -z: x = int(z // 1 + 1) else: x = int(z // 1) s = 0 for i in range(N): s += (a[i] - x) ** 2 print(s)
p04025
<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,201,388
s786609403
p04025
u333139319
1530737041
Python
Python (3.4.3)
py
Accepted
17
2940
116
n=int(input()) a=[int(i) for i in input().split()] b=round(sum(a)/len(a)) c=0 for i in a: c=c+(i-b)**2 print(c)
p04025
<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,201,389
s339428239
p04025
u828847847
1529810677
Python
Python (2.7.6)
py
Accepted
13
2568
232
n = int(input()) arr = map(int,raw_input().split()) ma = max(arr) mi = min(arr) ans = float("inf") for i in range(mi,ma+1): count = 0 for j in range(n): count += (i - arr[j]) * (i - arr[j]) ans = min(ans,count) print ans
p04025
<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,201,390
s616073444
p04025
u136395536
1529674071
Python
Python (3.4.3)
py
Accepted
17
3060
166
N = int(input()) a = [int(i) for i in input().split()] total = sum(a) ave = int(round(total/N)) ans = 0 for i in range(N): ans = ans + (a[i]-ave)**2 print(ans)
p04025
<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,201,391
s040225792
p04025
u517190578
1528971930
Python
Python (3.4.3)
py
Accepted
17
2940
146
n=int(input()) l = input() l = [int(i) for i in l.split()] e = sum(l) t = round(e/n) ans = 0 for i in l : ans = ans + (t-i)**2 print(ans)
p04025
<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,201,392
s565549902
p04025
u536081558
1528684841
Python
Python (2.7.6)
py
Accepted
10
2696
115
n = input() a = map(int, raw_input().split()) x = (sum(a) + len(a) / 2) / len(a) print sum((i - x) ** 2 for i in a)
p04025
<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,201,393
s873961044
p04025
u667024514
1526350722
Python
Python (3.4.3)
py
Accepted
18
3064
230
import math n= int(input()) lis = list(map(int,input().split())) a = math.floor(sum(lis)/n) b = math.ceil(sum(lis)/n) cou = 0 co = 0 for i in range(n): cou += abs(lis[i] - a) ** 2 co += abs(lis[i] - b ) ** 2 print(min(cou,co))
p04025
<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,201,394
s510097516
p04025
u766407523
1525641858
Python
Python (3.4.3)
py
Accepted
24
3060
193
N = int(input()) a = list(map(int, input().split())) cost = 100000000 for i in range(-100, 101): temp = 0 for a_i in a: temp += (a_i-i)**2 cost = min(cost, temp) print(cost)
p04025
<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,201,395
s378622998
p04025
u181037878
1525297900
Python
Python (3.4.3)
py
Accepted
25
3060
186
N = int(input()) A = list(map(int, input().split())) def cost(x, y): return (x - y) ** 2 ans = min([sum([cost(A[i], a) for i in range(N)]) for a in range(-100, 101)]) print(ans)
p04025
<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,201,396
s415629175
p04025
u520158330
1524851577
Python
Python (3.4.3)
py
Accepted
18
2940
145
N = int(input()) A = list(map(int,input().split()))[:N] a = int(round(sum(A)/N)) cost = 0 for i in A: cost += (i-a)*(i-a) print(cost)
p04025
<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,201,397
s467443966
p04025
u856232850
1524376002
Python
Python (3.4.3)
py
Accepted
25
3060
259
n = int(input()) a = list(map(int,input().split())) b = max(a) c = min(a) ans = 99999999999999999999999999999999999999999999999999999 for i in range(c,b+1): count = 0 for j in range(n): count += (i-a[j])**2 ans = min(ans,count) print(ans)
p04025
<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,201,398
s791565889
p04025
u562016607
1523587420
Python
Python (3.4.3)
py
Accepted
17
3064
208
N=int(input()) a=[int(i) for i in input().split()] av=sum(a)//N x=sum([(a[i]-av-1)**2 for i in range(N)]) y=sum([(a[i]-av)**2 for i in range(N)]) z=sum([(a[i]-av+1)**2 for i in range(N)]) print(min([x,y,z]))
p04025
<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,201,399
s510040597
p04025
u839857256
1522879409
Python
Python (3.4.3)
py
Accepted
24
2940
192
n = int(input()) a = list(map(int, input().split())) cost = 10**7 for l in range(min(a), max(a)+1): tmp = 0 for i in a: tmp += (i-l)**2 cost = min(cost, tmp) print(cost)
p04025
<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,201,400
s453956886
p04025
u276192130
1522877771
Python
Python (3.4.3)
py
Accepted
25
3060
196
n = int(input()) a = list(map(int, input().split())) cost = [] for i in range(-100, 100+1): temp = 0 for j in range(n): temp += (a[j] - i)**2 cost.append(temp) print(min(cost))
p04025
<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,201,401
s201214332
p04025
u030726788
1521595316
Python
Python (3.4.3)
py
Accepted
17
3064
231
n=int(input()) a=list(map(int,input().split())) ave=sum(a)//n mi=10**15 c=0 for i in a: c+=(i-ave)**2 mi=min(mi,c) ave+=1 c=0 for i in a: c+=(i-ave)**2 mi=min(mi,c) ave-=2 c=0 for i in a: c+=(i-ave)**2 mi=min(mi,c) print(mi)
p04025
<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,201,402
s579500493
p04025
u667024514
1521213254
Python
Python (3.4.3)
py
Accepted
17
3064
230
import math n = int(input()) lis = list(map(int,input().split())) co = 0 cou = 0 a = math.floor(sum(lis)/n) b = math.ceil(sum(lis)/n) for i in range(n): co += (abs(a-lis[i])) ** 2 cou += (abs(b-lis[i])) ** 2 print(min(co,cou))
p04025
<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,201,403
s191866494
p04025
u143492911
1520547170
Python
Python (3.4.3)
py
Accepted
25
2940
175
n=int(input()) a=list(map(int,input().split())) cost=0 ans=[] for i in range(-100,101): for j in a: cost+=(i-j)**2 ans.append(cost) cost=0 print(min(ans))
p04025
<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,201,404
s382570756
p04025
u319612498
1520019318
Python
Python (3.4.3)
py
Accepted
27
3060
197
n=int(input()) a=sorted(list(map(int,input().split()))) ans=float('inf') for i in range(a[0],a[-1]+1): tot=0 for j in range(len(a)): tot+=(a[j]-i)**2 ans=min(ans,tot) print(ans)
p04025
<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,201,405
s531405560
p04025
u926678805
1519935700
Python
Python (3.4.3)
py
Accepted
17
3060
151
n=int(input()) a=list(map(int,input().split())) x=int(sum(a)/len(a)+(0.5 if sum(a)/len(a)>0 else -0.5)) ans=0 for m in a: ans+=(m-x)**2 print(ans)
p04025
<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,201,406
s493655645
p04025
u482969053
1518459083
Python
Python (3.4.3)
py
Accepted
24
2940
264
def solve(): N = int(input()) a = list(map(int, input().split())) ans = float("inf") for i in range(min(a),max(a)+1): cost = 0 for a_i in a: cost += abs(i-a_i)**2 ans = min(ans, cost) print(ans) solve()
p04025
<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,201,407
s057095031
p04025
u451017206
1515279851
Python
Python (3.4.3)
py
Accepted
19
3188
112
n = int(input()) a = [int(i) for i in input().split()] y = round(sum(a)/n) print(sum(map(lambda x: (x-y)**2,a)))
p04025
<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,201,408
s316993268
p04025
u207056619
1515162001
Python
Python (3.4.3)
py
Accepted
25
2940
234
#!/usr/bin/env python3 _ = int(input()) a = list(map(int, input().split())) result = float('inf') for y in range(min(a), max(a) + 1): acc = 0 for x in a: acc += (x - y) ** 2 result = min(result, acc) print(result)
p04025
<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,201,409
s672452195
p04025
u858748695
1509478556
Python
Python (3.4.3)
py
Accepted
21
3192
291
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import math N = int(input()) a = list(map(int, input().split())) aves = [sum(a) // N, math.ceil(sum(a) / N)] ans = float('inf') for am in aves: acc = 0 for ai in a: acc += abs(am - ai) ** 2 ans = min(ans, acc) print(ans)
p04025
<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,201,410
s984080780
p04025
u663710122
1507671641
Python
Python (3.4.3)
py
Accepted
18
3064
124
N = int(input()) A = list(map(int, input().split())) ave = round(sum(A) / N) print(sum(map(lambda n: (n - ave) ** 2, A)))
p04025
<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,201,411
s588524863
p04025
u254456372
1507237199
Python
Python (3.4.3)
py
Accepted
18
3188
335
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """微分 """ import math def cost(A, x): return sum((x-a)**2 for a in A) def main(): N = int(input()) A = list(map(int, input().split())) x = sum(A) / N; ans = min(cost(A, math.ceil(x)), cost(A, math.floor(x))) print(ans) if __name__ == "__main_...
p04025
<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,201,412
s327780747
p04025
u835482198
1500852868
Python
Python (3.4.3)
py
Accepted
26
3060
232
N = int(input()) a = list(map(int, input().split())) total_cost = float('inf') for n in range(-100, 101): cost = 0 for i in range(N): cost += (a[i] - n) ** 2 total_cost = min(total_cost, cost) print(total_cost)
p04025
<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,201,413
s846952095
p04025
u867933941
1499315079
Python
Python (2.7.6)
py
Accepted
13
2568
171
N = input() an = map(int,raw_input().split(" ")) ans = 10**9 for i in range(-100,101): x = 0 for a in an: x += (a - i) ** 2 ans = min(x,ans) print ans
p04025
<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,201,414
s384997329
p04025
u481333386
1491680113
Python
Python (3.4.3)
py
Accepted
25
3064
465
def main(n, ns): if len(set(ns)) == 1: return 0 min_v = min(ns) max_v = max(ns) answer = pow(100, 3) for i in range(min_v, max_v + 1): cost = 0 for j in ns: if i == j: continue cost += pow((j - i), 2) answer = min(answer,...
p04025
<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,201,415
s089605668
p04025
u481333386
1491679956
Python
Python (3.4.3)
py
Accepted
23
3060
377
def main(n, ns): if len(set(ns)) == 1: return 0 min_v = -100 max_v = 101 answer = pow(100, 3) for i in range(min_v, max_v): cost = sum([(n - i) ** 2 for n in ns]) answer = min(answer, cost) return answer if __name__ == '__main__': n = int(input()) ns = ...
p04025
<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,201,416
s710298022
p04025
u433219236
1491102925
Python
Python (2.7.6)
py
Accepted
14
2568
279
# coding: utf-8 n = int(input()) a = list(map(int, raw_input().split())) a.sort() ans = 1000000007 for x in range(a[0], a[n - 1]): keep = 0 for i in range(n): keep += (a[i] - x) * (a[i] - x) ans = min(keep, ans) if a[0] == a[n - 1]: ans = 0 print(ans)
p04025
<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,201,417
s437096470
p04025
u382423941
1472862680
Python
Python (3.4.3)
py
Accepted
43
3188
134
n = int(input()) A = [int(_) for _ in input().split()] ave = round(sum(A)/len(A)) ans = sum([(a-ave)*(a-ave) for a in A]) print(ans)
p04025
<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,201,418
s944665195
p04025
u326356738
1471764443
Python
Python (3.4.3)
py
Accepted
40
3064
204
n = int(input()) a = [int(i) for i in input().split(' ')] ave = sum(a) / n if (ave - int(ave)) < 0.5: ave = int(ave) else: ave = int(ave) + 1 res = 0 for i in a: res += (i - ave)**2 print(res)
p04025
<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,201,419
s878163833
p04025
u459713533
1471633569
Python
Python (2.7.6)
py
Accepted
33
2568
263
#! /usr/bin/env python # -*- coding : utf-8 -*- import math import sys def main() : lines=sys.stdin.readlines() N=int(lines[0]) l=map(int, lines[1].split(" ")) x=int(round(1.0*sum(l)/N)) print sum(pow(a-x, 2) for a in l) if __name__=="__main__" : main()
p04025
<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,201,420
s150000074
p04025
u459713533
1471627275
Python
Python (2.7.6)
py
Accepted
34
2820
297
#! /usr/bin/env python # -*- coding : utf-8 -*- import sys def main() : lines=sys.stdin.readlines() N=int(lines[0]) l=map(int, lines[1].split(" ")) af=1.0*sum(l)/N ai=int(af) x=min(ai, ai+1, key=lambda a: abs(a-af)) print sum((a-x)**2 for a in l) if __name__=="__main__" : main()
p04025
<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,201,421
s500049758
p04025
u420637901
1471488068
Python
Python (2.7.6)
py
Accepted
31
2568
219
# coding: utf-8 a = int(raw_input()) b_list = map(int, raw_input().split()) loss_list = [] for i in range(-100, 101): loss = [(i - b) * (i - b) for b in b_list] loss_list.append(sum(loss)) print min(loss_list)
p04025
<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,201,422
s950006253
p04025
u145496715
1471433889
Python
PyPy2 (5.6.0)
py
Accepted
88
10864
229
n = int(raw_input()) values = list(map(int, raw_input().split())) best = 200 ** 3 for target in range(-100, 101): cost = 0 for value in values: cost += (target - value) ** 2 best = min(best, cost) print(best)
p04025
<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,201,423
s767564199
p04025
u116275728
1471430133
Python
Python (3.4.3)
py
Accepted
52
3188
199
N = int(input()) a = list(map(int, input().split())) ret = N * 200**2 for i in range(-100, 101): cost = 0 for j in range(N): cost += (i - a[j])**2 ret = min(ret, cost) print(ret)
p04025
<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,201,424
s791875114
p04025
u461954362
1471329312
Python
Python (3.4.3)
py
Accepted
53
3064
367
#!/usr/bin/env python # -*- coding:utf-8 -*- from __future__ import division, print_function, absolute_import, unicode_literals N = int(input()) A = list(map(int, input().split())) minimum_score = float('inf') for i in range(-100, 101): score = 0 for a in A: score += (a - i) ** 2 minimum_score = ...
p04025
<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,201,425
s261262877
p04025
u352021237
1471302762
Python
PyPy2 (5.6.0)
py
Accepted
65
8944
154
n=int(raw_input()) N=map(int,raw_input().split()) add=count=0 b=sum(N)/n a=b+1 for i in N: add+=(a-i)**2 count+=(b-i)**2 print min(add,count)
p04025
<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,201,426
s443943938
p04025
u725662235
1471224031
Python
Python (2.7.6)
py
Accepted
27
2568
141
n = input() a = map(int,raw_input().split()) avg = int(round(float(sum(a))/n)) # print avg d = 0 for i in a: d += (i - avg) ** 2 print d
p04025
<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,201,427
s049830575
p04025
u351657462
1471159256
Python
Python (2.7.6)
py
Accepted
28
2568
204
n=int(raw_input()) l=map(int,raw_input().split()) sm,avg,cost1,cost2=0,0,0,0 for el in l: sm+=el avg1=sm//n avg2=avg1+1 for el in l: cost1+=(avg1-el)**2 cost2+=(avg2-el)**2 print min(cost2,cost1)
p04025
<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,201,428
s094719081
p04025
u159043787
1471140227
Python
Python (2.7.6)
py
Accepted
27
2568
292
N = input() a = map(int, raw_input().split( )) mean = sum(a)/len(a) upper = mean+1 lower = mean-1 cost = sum(map(lambda x: (x - mean)*(x - mean), a)) costU = sum(map(lambda x: (x - upper)*(x - upper), a)) costL = sum(map(lambda x: (x - lower)*(x - lower), a)) print min(cost,costU,costL)
p04025
<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,201,429
s892737618
p04025
u941268675
1471138918
Python
Python (2.7.6)
py
Accepted
28
2820
114
n = input() A = map(int, raw_input().split()) m = sum(A) / float(n) print int(sum((v - round(m))**2 for v in A))
p04025
<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,201,430
s125948703
p04025
u813098295
1471137902
Python
Python (2.7.6)
py
Accepted
32
2568
323
# coding: utf-8 def cost(n, a, m): hihumi = 0 #hihumi => 滝本ひふみ for i in range(n): hihumi += (a[i] - m) ** 2 return hihumi N = int(raw_input()) a = map(int, raw_input().split()) ans = 1000000000000 for i in range(min(a), max(a) + 1): if (ans > cost(N, a, i)): ans = cost(N, a, i) print ans
p04025
<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,201,431
s454658022
p04025
u638629468
1471137821
Python
Python (2.7.6)
py
Accepted
30
2692
265
import sys import math line1 = sys.stdin.readline() line2 = sys.stdin.readline() n = int(line1) a_array = [int(x) for x in line2.split()] y = int(round(float(reduce(lambda x, y: x + y, a_array)) / n)) print reduce(lambda x, y: x+y, [(x - y) ** 2 for x in a_array])
p04025
<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,201,432
s072908855
p04025
u237168895
1471137598
Python
Python (3.4.3)
py
Accepted
39
3064
319
import math N = int(input()) m = [ int(i) for i in input().strip().split(" ")] k_tmp = float(sum(m))/len(m) k1 = int(math.ceil(k_tmp)) k2 = int(math.floor(k_tmp)) res1 = sum([(x-k1) * (x-k1) for x in m]) res2 = sum([(x-k2) * (x-k2) for x in m]) res = 0 if res1 > res2: res = res2 else: res = res1 print(res)
p04025
<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,201,433
s664236734
p04025
u945080461
1471137361
Python
Python (2.7.6)
py
Accepted
26
2568
122
n = int(raw_input()) a = map(int, raw_input().split()) y = int(round(1.0 * sum(a) / n)) print sum((y - x) ** 2 for x in a)
p04025
<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,201,434
s968667070
p04025
u509661905
1471137200
Python
Python (3.4.3)
py
Accepted
45
3188
394
#!/usr/bin/env python3 def cost(x, y): return (x - y) * (x - y) def min_total_cost(xs): def total_cost(target): return sum(cost(x, target) for x in xs) ans = min(total_cost(t) for t in range(min(xs), max(xs) + 1)) return ans def main(): _ = input() xs = list(map(int, input().split(...
p04025
<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,201,435
s577348013
p04025
u357487020
1471137185
Python
Python (2.7.6)
py
Accepted
32
2568
172
n=input() a=map(int,raw_input().split()) ans=10**9 for j in xrange(-100,101): asum=0 for i in xrange(n): asum+=(a[i]-j)**2 ans=min(ans,asum) print(ans)
p04025
<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,201,436
s131842942
p04025
u132291455
1471136950
Python
Python (2.7.6)
py
Accepted
29
2944
1,603
import bisect import sys import math import itertools sys.setrecursionlimit(10000) INF = float('inf') # input macro def i(): return int(raw_input()) def ii(): return map(int,raw_input().split(" ")) def s(): return raw_input() def ss(): return raw_input().split(" ") def slist(): return list(raw_inp...
p04025
<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,201,437
s555503680
p04025
u810735437
1471136875
Python
Python (3.4.3)
py
Accepted
48
3188
245
#!/usr/bin/env python3 # -*- coding: utf-8 -*- N = int(input()) As = list(map(int,input().split())) mn_cost = 1e10 for v in range(-100,101): cost = sum((v - a) ** 2 for a in As) if cost < mn_cost: mn_cost = cost print(mn_cost)
p04025
<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,201,438
s900244192
p04025
u230117534
1471136819
Python
Python (3.4.3)
py
Accepted
40
3064
238
import math N = int(input()) a = [int(i) for i in input().strip().split(" ")] a_h = math.ceil(sum(a) / len(a)) a_l = math.floor(sum(a) / len(a)) d_h = sum([(a_h-i)**2 for i in a]) d_l = sum([(a_l-i)**2 for i in a]) print(min(d_h,d_l))
p04025
<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,201,439
s182091070
p04025
u156163787
1471136744
Python
Python (3.4.3)
py
Accepted
48
3064
220
while 1: try: n=int(input()) a=list(map(int,input().split())) except: break res=float('inf') for p in range(min(a),max(a)+1): res=min(res,sum((x-p)**2 for x in a)) print(res)
p04025
<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,201,440
s372289256
p04025
u024612773
1471136732
Python
Python (3.4.3)
py
Accepted
38
3064
126
n=int(input()) a=list(map(int,input().split())) m=round(sum(a)/n) ans = 0 for i in range(n): ans += (a[i]-m)**2 print(ans)
p04025
<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,201,441
s298923898
p04025
u620084012
1471136731
Python
Python (3.4.3)
py
Accepted
40
3064
218
N = int(input()) a = list(map(int, input().split())) m = sum(a)//N ans1 = 0 ans2 = 0 ans3 = 0 for k in range(N): ans1 += (a[k]-m)**2 ans2 += (a[k]-m-1)**2 ans3 += (a[k]-m+1)**2 print(min(ans1,ans2,ans3))
p04025
<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,201,442
s986957145
p04025
u499893886
1471136729
Python
Python (3.4.3)
py
Accepted
40
3188
151
N=int(input()) A=list(map(int,input().split())) Y=sum(A) // N Sol=10**9 for y in range(Y-2,Y+2): Sol=min(Sol,sum(((a-y)**2 for a in A))) print(Sol)
p04025
<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,201,443
s248757529
p04025
u707500405
1471136660
Python
Python (2.7.6)
py
Accepted
31
2568
180
N = int(raw_input()) a = map(int,raw_input().split()) ans = 10**9+7 for i in xrange(-100,101): cost = sum((i-a[j])**2 for j in xrange(N)) if cost < ans: ans = cost print ans
p04025
<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,201,444
s557221125
p04025
u202619899
1471136607
Python
Python (3.4.3)
py
Accepted
45
3188
224
N = int(input()) A = list(map(int, input().split())) res = 1<<30 cand = -100 while cand <= 100: tmp = 0 for a in A: dif = cand - a tmp += dif*dif res = min(res, tmp) cand += 1 print(res)
p04025
<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,201,445
s263717284
p04025
u315078622
1471136601
Python
Python (3.4.3)
py
Accepted
66
3064
118
N = int(input()) A = [int(x) for x in input().split()] print(min(sum((a-x)**2 for a in A) for x in range(-100, 101)))
p04025
<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,201,446
s454585669
p04029
u961469795
1601525726
Python
Python (3.8.2)
py
Accepted
23
9064
73
N = int(input()) ans = 0 for i in range(N): ans += i + 1 print(ans)
p04029
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give <var>1</var> candy to the first child in the line, <var>2</var> candies to the second chil...
3
6
1,201,657
s442370655
p04029
u554784585
1601524047
Python
Python (3.8.2)
py
Accepted
26
8996
33
N=int(input()) print((1+N)*N//2)
p04029
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give <var>1</var> candy to the first child in the line, <var>2</var> candies to the second chil...
3
6
1,201,658
s547471366
p04029
u582765213
1601516571
Python
Python (3.8.2)
py
Accepted
28
9036
52
N = int(input()) candy=(1+N)*N/2 print(int(candy))
p04029
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give <var>1</var> candy to the first child in the line, <var>2</var> candies to the second chil...
3
6
1,201,659
s051952112
p04029
u307133884
1601424016
Python
Python (3.8.2)
py
Accepted
25
8804
67
N = int(input()) cnt = 0 for i in range(N+1): cnt += i print(cnt)
p04029
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give <var>1</var> candy to the first child in the line, <var>2</var> candies to the second chil...
3
6
1,201,660
s762117434
p04029
u763550415
1601337227
Python
Python (3.8.2)
py
Accepted
28
9080
52
N = int(input()) L = list(range(N+1)) print(sum(L))
p04029
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give <var>1</var> candy to the first child in the line, <var>2</var> candies to the second chil...
3
6
1,201,661
s851230338
p04029
u318661636
1601295979
Python
Python (3.8.2)
py
Accepted
24
9048
40
n = int(input()) print(sum(range(n+1)))
p04029
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give <var>1</var> candy to the first child in the line, <var>2</var> candies to the second chil...
3
6
1,201,662
s352579467
p04029
u775501928
1601257458
Python
Python (3.8.2)
py
Accepted
20
9148
73
N = int(input()) sum = 0 for i in range(1,N+1): sum += i print(sum)
p04029
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give <var>1</var> candy to the first child in the line, <var>2</var> candies to the second chil...
3
6
1,201,663
s865229076
p04029
u401183062
1601222601
Python
Python (3.8.2)
py
Accepted
26
9112
161
def iroha(): count = int(input()) result = 0 for i in range(count+1): result += i print(result) if __name__ == "__main__": iroha()
p04029
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give <var>1</var> candy to the first child in the line, <var>2</var> candies to the second chil...
3
6
1,201,664
s258155178
p04029
u015084832
1601177461
Python
Python (3.8.2)
py
Accepted
25
9028
119
def main(): n = int(input()) ans = int(n * (n+1) / 2) print(ans) if __name__ == '__main__': main()
p04029
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give <var>1</var> candy to the first child in the line, <var>2</var> candies to the second chil...
3
6
1,201,665
s916220598
p04029
u521323621
1601168981
Python
Python (3.8.2)
py
Accepted
21
9136
36
n = int(input()) print(n*(n+1)//2)
p04029
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give <var>1</var> candy to the first child in the line, <var>2</var> candies to the second chil...
3
6
1,201,666
s332417114
p04029
u313103408
1601156451
Python
Python (3.8.2)
py
Accepted
25
9052
40
n = int(input()) print(int(n*(n+1)/2))
p04029
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give <var>1</var> candy to the first child in the line, <var>2</var> candies to the second chil...
3
6
1,201,667
s167826690
p04029
u197273335
1601100508
Python
Python (3.8.2)
py
Accepted
24
9076
69
N = int(input()) a = 0 for i in range(1,N + 1): a =i + a print(a)
p04029
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give <var>1</var> candy to the first child in the line, <var>2</var> candies to the second chil...
3
6
1,201,668
s653288904
p04029
u713574885
1601092205
Python
Python (3.8.2)
py
Accepted
28
9072
99
n=int(input()) memo=[0]*110 memo[1]=1 for i in range(2,105): memo[i]=memo[i-1]+i print(memo[n])
p04029
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give <var>1</var> candy to the first child in the line, <var>2</var> candies to the second chil...
3
6
1,201,669
s389400619
p04029
u723792785
1600988407
Python
Python (3.8.2)
py
Accepted
27
9140
32
n=int(input());print(n*(n+1)//2)
p04029
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give <var>1</var> candy to the first child in the line, <var>2</var> candies to the second chil...
3
6
1,201,670
s860893967
p04029
u161778051
1600964716
Python
Python (3.8.2)
py
Accepted
21
8924
36
n = int(input()) print((n*(n+1))//2)
p04029
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give <var>1</var> candy to the first child in the line, <var>2</var> candies to the second chil...
3
6
1,201,671
s608395725
p04029
u245641078
1600929011
Python
Python (3.8.2)
py
Accepted
26
9084
58
N=int(input());num=0 for i in range(N):num+=i+1 print(num)
p04029
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give <var>1</var> candy to the first child in the line, <var>2</var> candies to the second chil...
3
6
1,201,672
s091035313
p04029
u556477263
1600912378
Python
Python (3.8.2)
py
Accepted
28
9064
66
n = int(input()) c = 0 while n!=0: c += n n -= 1 print(c)
p04029
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give <var>1</var> candy to the first child in the line, <var>2</var> candies to the second chil...
3
6
1,201,673
s340208090
p04029
u336564899
1600883047
Python
Python (3.8.2)
py
Accepted
27
8972
150
""" ABC043 A キャンディーとN人の子供イージー https://atcoder.jp/contests/abc043/tasks/abc043_a """ x = int(input()) print(x*(x+1)//2)
p04029
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give <var>1</var> candy to the first child in the line, <var>2</var> candies to the second chil...
3
6
1,201,674
s434380478
p04029
u045505231
1600755733
Python
Python (3.8.2)
py
Accepted
24
9404
106
import math from datetime import date def main(): n = int(input()) print(n * (n + 1) // 2) main()
p04029
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give <var>1</var> candy to the first child in the line, <var>2</var> candies to the second chil...
3
6
1,201,675
s079836212
p04029
u825685913
1600649184
Python
Python (3.8.2)
py
Accepted
27
9092
34
N = int(input()) print(N*(N+1)//2)
p04029
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give <var>1</var> candy to the first child in the line, <var>2</var> candies to the second chil...
3
6
1,201,676
s984738100
p04029
u097700948
1600638906
Python
Python (3.8.2)
py
Accepted
27
9088
50
N = int(input()) ans = int(N*(N+1)/2) print(ans)
p04029
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give <var>1</var> candy to the first child in the line, <var>2</var> candies to the second chil...
3
6
1,201,677
s592426209
p04029
u699296734
1600634772
Python
Python (3.8.2)
py
Accepted
24
9000
51
n = int(input()) res = n * (n + 1) // 2 print(res)
p04029
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give <var>1</var> candy to the first child in the line, <var>2</var> candies to the second chil...
3
6
1,201,678
s094472825
p04029
u367397360
1600632765
Python
Python (3.8.2)
py
Accepted
31
8988
122
# Nの入力受付 N = int(input()) # 1~Nの合計を計算 SUM = 0 for i in range(N): SUM = SUM + i + 1 print(SUM)
p04029
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give <var>1</var> candy to the first child in the line, <var>2</var> candies to the second chil...
3
6
1,201,679
s157956651
p04029
u348216768
1600605550
Python
Python (3.8.2)
py
Accepted
28
8936
39
N=int(input()) print(int((N*(N+1))/2))
p04029
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give <var>1</var> candy to the first child in the line, <var>2</var> candies to the second chil...
3
6
1,201,680