結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,024 KB
testcase_01 WA -
testcase_02 AC 11 ms
6,148 KB
testcase_03 AC 11 ms
6,008 KB
testcase_04 AC 11 ms
5,988 KB
testcase_05 AC 11 ms
5,916 KB
testcase_06 AC 11 ms
5,912 KB
testcase_07 WA -
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
5,944 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,972 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 i>0:
# print ans
# else:
print ans/2

0