結果

問題 No.1687 What the Heck?
ユーザー nephrologistnephrologist
提出日時 2021-09-25 12:05:36
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 942 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 87,052 KB
実行使用メモリ 107,792 KB
最終ジャッジ日時 2023-09-18 22:59:14
合計ジャッジ時間 7,007 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 68 ms
71,276 KB
testcase_02 WA -
testcase_03 AC 69 ms
71,248 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

# from itertools import permutations

# n = 6
# kumiawase = list(permutations(range(1, n + 1), n))
# ans = 0
# goukei = n * (n + 1) // 2
# for kumi1 in kumiawase:
#     expected = n * (n + 1) // 2
#     for i in range(n):
#         if kumi1[i] == n:
#             expected -= 2 * (i + 1)
#         for kumi2 in kumiawase:
#             res = 0
#             for i in range(n):
#                 p = kumi1[i]
#                 k = kumi2[i]
#                 if k > p:
#                     res += i + 1
#                 elif p > k:
#                     res -= i + 1
#             if res > expected:
#                 print(kumi1, kumi2, res, expected)
#             ans = max(ans, res)
# print(ans)

n = int(input())
P = list(map(int, input().split()))

PP = [(p, i) for i, p in enumerate(P)]
PP.sort(reverse=True)
ans = 0
for idx, (p, i) in enumerate(PP):
    ans = max(ans, (n - idx - 1) * (n - idx) // 2 - (2 * i + 1))
print(max(0, ans))
0