結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 9 ms
6,096 KB
testcase_02 WA -
testcase_03 AC 9 ms
5,904 KB
testcase_04 WA -
testcase_05 AC 9 ms
6,016 KB
testcase_06 WA -
testcase_07 AC 9 ms
5,992 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
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 WA -
権限があれば一括ダウンロードができます

ソースコード

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 i>0:
    print ans
else:
    print ans/2
0