結果

問題 No.831 都市めぐり
ユーザー kuuso1kuuso1
提出日時 2019-05-24 22:07:00
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 212 ms / 2,000 ms
コード長 892 bytes
コンパイル時間 206 ms
コンパイル使用メモリ 81,716 KB
実行使用メモリ 145,224 KB
最終ジャッジ日時 2023-10-17 12:38:38
合計ジャッジ時間 2,754 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
55,424 KB
testcase_01 AC 42 ms
55,424 KB
testcase_02 AC 42 ms
55,424 KB
testcase_03 AC 41 ms
55,424 KB
testcase_04 AC 42 ms
55,424 KB
testcase_05 AC 42 ms
55,424 KB
testcase_06 AC 56 ms
61,964 KB
testcase_07 AC 56 ms
64,128 KB
testcase_08 AC 55 ms
64,128 KB
testcase_09 AC 52 ms
62,064 KB
testcase_10 AC 56 ms
64,128 KB
testcase_11 AC 56 ms
64,128 KB
testcase_12 AC 65 ms
71,100 KB
testcase_13 AC 62 ms
68,920 KB
testcase_14 AC 63 ms
71,100 KB
testcase_15 AC 115 ms
96,644 KB
testcase_16 AC 91 ms
87,004 KB
testcase_17 AC 144 ms
113,552 KB
testcase_18 AC 159 ms
119,000 KB
testcase_19 AC 211 ms
145,224 KB
testcase_20 AC 212 ms
145,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin
from collections import deque
##  input functions for me
def ria(sep = ''):
    if sep == '' :
        return list(map(int, input().split())) 
    else: return list(map(int, input().split(sep)))
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##

## main ##
N = ri()
if N == 1:
    print (0)
    exit(0)

L = deque()
for i in range(2, N + 1): L.append(i)
R = deque()
R.append(1)
c = 0
while len(L) > 0 :
    if c == 0: R.append(L.pop())
    elif c == 1: R.appendleft(L.pop())
    elif c == 2: R.append(L.popleft())
    elif c == 3: R.appendleft(L.popleft())
    c += 1
    if c >= 4 : c -= 4

sc = 0
ll = list(R)
#print(ll)
for i in range(N):
    sc += ll[i] * ll[(i + 1) % N] + (ll[(i + 1) % N] - ll[i])
print (sc)









0