結果

問題 No.831 都市めぐり
ユーザー kamojirokamojiro
提出日時 2019-05-24 22:14:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 942 bytes
コンパイル時間 1,212 ms
コンパイル使用メモリ 81,516 KB
実行使用メモリ 77,264 KB
最終ジャッジ日時 2023-10-17 12:47:20
合計ジャッジ時間 3,331 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,468 KB
testcase_01 AC 42 ms
53,468 KB
testcase_02 AC 41 ms
55,516 KB
testcase_03 AC 41 ms
53,468 KB
testcase_04 AC 41 ms
55,516 KB
testcase_05 AC 41 ms
55,516 KB
testcase_06 AC 46 ms
59,440 KB
testcase_07 AC 48 ms
61,632 KB
testcase_08 AC 48 ms
61,632 KB
testcase_09 AC 45 ms
59,440 KB
testcase_10 AC 48 ms
61,632 KB
testcase_11 AC 48 ms
61,632 KB
testcase_12 AC 49 ms
62,420 KB
testcase_13 AC 48 ms
62,288 KB
testcase_14 AC 49 ms
62,420 KB
testcase_15 AC 56 ms
68,196 KB
testcase_16 AC 52 ms
64,360 KB
testcase_17 AC 59 ms
69,452 KB
testcase_18 AC 61 ms
71,780 KB
testcase_19 AC 67 ms
76,696 KB
testcase_20 AC 68 ms
77,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
N = int( input())
if N == 1:
    ans = 0
else:
    ans = 0
    # d = deque()
    d = [0]*N
    t = N//2
    if N%2 == 0:
        for i in range(t):
            if i%2 == 0:
                d[t-i-1] = t-i
                d[t+i] = t+1+i
                # d.appendleft(t-i)
                # d.append(t+1+i)
            else:
                d[t-i-1] = t+1+i
                d[t+i] = t-i
                # d.appendleft(t+1+i)
                # d.append(t-i)
    else:
        # d.append(t+1)
        d[t] = t + 1
        for i in range(t):
            if i%2 == 0:
                d[t-1-i] = t-i
                d[t+i+1] = t+i+2
                # d.appendleft(t-i)
                # d.append(t+i+2)
            else:
                d[t-1-i] = t+i+2
                d[t+i+1] = t-i
                # d.appendleft(t+i+2)
                # d.append(t-i)
    for i in range(N):
        ans += d[i]*d[(i+1)%N]
print(ans)
0