結果
| 問題 |
No.831 都市めぐり
|
| コンテスト | |
| ユーザー |
vwxyz
|
| 提出日時 | 2024-04-07 22:37:25 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 923 ms / 2,000 ms |
| コード長 | 497 bytes |
| コンパイル時間 | 181 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 145,244 KB |
| 最終ジャッジ日時 | 2024-10-01 04:48:17 |
| 合計ジャッジ時間 | 4,985 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
ソースコード
from collections import deque
N=int(input())
if N==1:
ans=0
else:
queue=deque([x for x in range(2,N+1)])
L=[1]
R=[1]
b=1
while queue:
if len(queue)==1:
L.append(queue.pop())
break
if b:
R.append(queue.pop())
L.append(queue.pop())
else:
R.append(queue.popleft())
L.append(queue.popleft())
b^=1
tour=L+R[::-1]
ans=sum(a*b for a,b in zip(tour,tour[1:]))
print(ans)
vwxyz