結果

問題 No.831 都市めぐり
ユーザー kuuso1
提出日時 2019-05-24 22:05:26
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 854 bytes
コンパイル時間 76 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 105,652 KB
最終ジャッジ日時 2024-09-17 10:42:54
合計ジャッジ時間 11,306 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
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()
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