結果

問題 No.77 レンガのピラミッド
ユーザー nari11111nari11111
提出日時 2014-11-26 00:28:58
言語 Python2
(2.7.18)
結果
AC  
実行時間 12 ms / 5,000 ms
コード長 952 bytes
コンパイル時間 561 ms
コンパイル使用メモリ 6,688 KB
実行使用メモリ 6,160 KB
最終ジャッジ日時 2023-09-01 22:05:40
合計ジャッジ時間 1,978 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,156 KB
testcase_01 AC 12 ms
6,156 KB
testcase_02 AC 11 ms
5,920 KB
testcase_03 AC 11 ms
5,896 KB
testcase_04 AC 11 ms
6,088 KB
testcase_05 AC 11 ms
6,072 KB
testcase_06 AC 11 ms
5,892 KB
testcase_07 AC 11 ms
6,120 KB
testcase_08 AC 11 ms
6,084 KB
testcase_09 AC 11 ms
5,912 KB
testcase_10 AC 11 ms
5,988 KB
testcase_11 AC 12 ms
6,120 KB
testcase_12 AC 12 ms
5,984 KB
testcase_13 AC 12 ms
6,160 KB
testcase_14 AC 11 ms
5,896 KB
testcase_15 AC 11 ms
5,912 KB
testcase_16 AC 11 ms
5,980 KB
testcase_17 AC 11 ms
5,932 KB
testcase_18 AC 11 ms
6,116 KB
testcase_19 AC 11 ms
5,996 KB
testcase_20 AC 12 ms
5,976 KB
testcase_21 AC 12 ms
6,040 KB
testcase_22 AC 12 ms
5,892 KB
testcase_23 AC 11 ms
6,128 KB
testcase_24 AC 12 ms
5,984 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

husoku=0
dasoku=0

n=-1
for i in xrange(1,r+1):
    n+=1
    sa=abs(p[n]-i)
    if p[n]>i:
        dasoku+=sa
    else:
        husoku+=sa


for i in xrange(r-1,0,-1):
    n+=1
    sa=abs(p[n]-i)
    if p[n]>i:
        dasoku+=sa
    else:
        husoku+=sa

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

print dasoku
# print husoku

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

0