結果

問題 No.77 レンガのピラミッド
ユーザー nari11111nari11111
提出日時 2014-11-26 00:12:56
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 853 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 6,692 KB
実行使用メモリ 6,192 KB
最終ジャッジ日時 2023-08-31 01:18:28
合計ジャッジ時間 1,333 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,168 KB
testcase_01 AC 11 ms
5,908 KB
testcase_02 AC 12 ms
6,132 KB
testcase_03 AC 12 ms
5,912 KB
testcase_04 AC 12 ms
5,920 KB
testcase_05 AC 12 ms
5,988 KB
testcase_06 AC 11 ms
6,152 KB
testcase_07 AC 11 ms
5,928 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 11 ms
6,028 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 11 ms
5,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

# p=[1, 1, 1, 1, 1, 1, 1, 1, 1]

numofstone = raw_input()
p = map(int,raw_input().split())

for i in xrange(100):
    p.append(0)

s = sum(p)
# print s

r = math.sqrt(s)

delete = 0

if r==int(r):
    r=int(r)
else:
    for i in xrange(1,1000):
        s-=1
        r = math.sqrt(s)
        if r==int(r):
            delete=i
            r=int(r)
            break

# print r
# print "delete",delete


# print r
# print

ans=0

n=-1
for i in xrange(1,r+1):
    n+=1
    sa=abs(p[n]-i)
    # print i, sa
    ans+=sa

for i in xrange(r-1,0,-1):
    n+=1
    sa=abs(p[n]-i)
    # print i,sa
    ans+=sa

# pyramid = 2*r-1
# zero = len(p)-pyramid

for i in xrange(2*r-1,len(p)):
    n+=1
    sa=p[n]
    # print 0,sa
    ans+=sa

if delete>0:
    print ans
else:
    print ans/2

0