結果

問題 No.831 都市めぐり
ユーザー kuuso1kuuso1
提出日時 2019-05-24 22:05:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 854 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 11,876 KB
実行使用メモリ 104,972 KB
最終ジャッジ日時 2023-10-17 12:37:09
合計ジャッジ時間 10,750 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,120 KB
testcase_01 WA -
testcase_02 AC 29 ms
10,120 KB
testcase_03 AC 29 ms
10,120 KB
testcase_04 AC 29 ms
10,120 KB
testcase_05 AC 30 ms
10,120 KB
testcase_06 AC 31 ms
10,160 KB
testcase_07 AC 34 ms
10,272 KB
testcase_08 AC 39 ms
10,484 KB
testcase_09 AC 30 ms
10,180 KB
testcase_10 AC 39 ms
10,516 KB
testcase_11 AC 38 ms
10,464 KB
testcase_12 AC 142 ms
14,816 KB
testcase_13 AC 128 ms
14,020 KB
testcase_14 AC 145 ms
14,816 KB
testcase_15 AC 1,004 ms
49,744 KB
testcase_16 AC 432 ms
26,512 KB
testcase_17 AC 1,247 ms
57,400 KB
testcase_18 AC 1,543 ms
71,648 KB
testcase_19 TLE -
testcase_20 TLE -
権限があれば一括ダウンロードができます

ソースコード

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()
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