結果

問題 No.831 都市めぐり
ユーザー simamumusimamumu
提出日時 2019-05-24 22:57:09
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 1,182 bytes
コンパイル時間 132 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 89,984 KB
最終ジャッジ日時 2024-09-17 11:50:07
合計ジャッジ時間 6,272 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

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]
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)
'''
0