結果
| 問題 |
No.831 都市めぐり
|
| コンテスト | |
| ユーザー |
simamumu
|
| 提出日時 | 2019-05-24 22:57:46 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 1,355 ms / 2,000 ms |
| コード長 | 1,217 bytes |
| コンパイル時間 | 216 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 89,856 KB |
| 最終ジャッジ日時 | 2024-09-17 11:51:48 |
| 合計ジャッジ時間 | 6,955 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
ソースコード
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())
N = int(input())
aa = []
if N%2 == 1:
for i in range(N):
if i%2 == 0:
aa.append(i+1)
else:
aa.append(N-i)
aa.append(1)
else:
for i in range(N):
if i < N//2:
if i%2 == 0:
aa.append(i+1)
else:
aa.append(N-i)
else:
if i%2 == 0:
aa.append(N-i)
else:
aa.append(i+1)
aa.append(1)
ans = 0
for i in range(N):
ans += aa[i]*aa[i+1]
if N == 1:
print(0)
else:
print(ans)
# 実験
'''
for L in range(1,N+1):
lists = list(itertools.permutations(range(1,L+1)))
ans = INF
ansl = []
for li in lists:
tmpl = list(li)
tmpl.append(tmpl[0])
tmpans = 0
for i in range(L):
tmpans += tmpl[i]*tmpl[i+1]
if tmpans < ans:
ans = tmpans
ansl = tmpl[:]
print(L,ansl,ans)
'''
simamumu