結果

問題 No.831 都市めぐり
ユーザー kuuso1
提出日時 2019-05-24 22:06:32
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 892 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 105,756 KB
最終ジャッジ日時 2024-09-17 10:43:19
合計ジャッジ時間 11,431 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16 TLE * 2
権限があれば一括ダウンロードができます

ソースコード

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