結果

問題 No.831 都市めぐり
ユーザー kamojirokamojiro
提出日時 2019-05-24 22:15:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,266 ms / 2,000 ms
コード長 942 bytes
コンパイル時間 106 ms
コンパイル使用メモリ 11,908 KB
実行使用メモリ 88,420 KB
最終ジャッジ日時 2023-10-17 12:47:56
合計ジャッジ時間 6,544 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,156 KB
testcase_01 AC 29 ms
10,156 KB
testcase_02 AC 29 ms
10,156 KB
testcase_03 AC 30 ms
10,156 KB
testcase_04 AC 30 ms
10,156 KB
testcase_05 AC 29 ms
10,156 KB
testcase_06 AC 30 ms
10,196 KB
testcase_07 AC 31 ms
10,300 KB
testcase_08 AC 35 ms
10,476 KB
testcase_09 AC 30 ms
10,216 KB
testcase_10 AC 36 ms
10,500 KB
testcase_11 AC 35 ms
10,460 KB
testcase_12 AC 93 ms
13,920 KB
testcase_13 AC 82 ms
13,128 KB
testcase_14 AC 91 ms
13,920 KB
testcase_15 AC 540 ms
42,756 KB
testcase_16 AC 242 ms
23,620 KB
testcase_17 AC 648 ms
49,092 KB
testcase_18 AC 802 ms
60,904 KB
testcase_19 AC 1,200 ms
85,516 KB
testcase_20 AC 1,266 ms
88,420 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