結果
問題 | No.831 都市めぐり |
ユーザー |
![]() |
提出日時 | 2019-05-24 22:07:00 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 214 ms / 2,000 ms |
コード長 | 892 bytes |
コンパイル時間 | 259 ms |
コンパイル使用メモリ | 82,816 KB |
実行使用メモリ | 145,792 KB |
最終ジャッジ日時 | 2024-09-17 10:44:17 |
合計ジャッジ時間 | 2,898 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
from sys import stdinfrom collections import deque## input functions for medef 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 = 0while 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 += 1if c >= 4 : c -= 4sc = 0ll = list(R)#print(ll)for i in range(N):sc += ll[i] * ll[(i + 1) % N] + (ll[(i + 1) % N] - ll[i])print (sc)