結果

問題 No.1687 What the Heck?
ユーザー U SU S
提出日時 2021-09-24 21:37:44
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 903 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 87,188 KB
実行使用メモリ 103,384 KB
最終ジャッジ日時 2023-09-18 20:54:17
合計ジャッジ時間 4,185 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
73,896 KB
testcase_01 AC 122 ms
74,032 KB
testcase_02 AC 117 ms
74,064 KB
testcase_03 AC 124 ms
73,964 KB
testcase_04 AC 116 ms
74,248 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 131 ms
87,356 KB
testcase_10 AC 127 ms
83,744 KB
testcase_11 AC 128 ms
83,916 KB
testcase_12 AC 167 ms
103,140 KB
testcase_13 AC 172 ms
103,264 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#import sys
# input = sys.stdin.readline
def mp():return map(int,input().split())
def lmp():return list(map(int,input().split()))
def mps(A):return [tuple(map(int, input().split())) for _ in range(A)]
import math
import bisect
import heapq
from copy import deepcopy as dc
from itertools import accumulate
from collections import Counter, defaultdict, deque
def ceil(U,V):return (U+V-1)//V
def modf1(N,MOD):return (N-1)%MOD+1
inf = int(1e20)
mod = int(1e9+7)
import itertools
def permutation_all(seq, choice):
    return list(itertools.permutations(seq, choice))

n = int(input())
p = lmp()
if n <= 3:
    ans = 0
    a = permutation_all([i for i in range(1,n+1)], n)
    for i in range(len(a)):
        cnt = 0
        for j in range(n):
            if p[j] < a[i][j]:cnt += j+1
            else:cnt -= j+1
        ans = max(ans,cnt)
    print(ans)
else:
    u = p.index(n)+1
    print(n*(n+1)//2-2*u)

0