結果

問題 No.1687 What the Heck?
ユーザー nephrologistnephrologist
提出日時 2021-09-25 12:07:27
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 983 bytes
コンパイル時間 2,280 ms
コンパイル使用メモリ 86,756 KB
実行使用メモリ 107,612 KB
最終ジャッジ日時 2023-09-18 22:59:24
合計ジャッジ時間 6,979 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,324 KB
testcase_01 AC 68 ms
71,484 KB
testcase_02 AC 68 ms
71,432 KB
testcase_03 AC 69 ms
71,376 KB
testcase_04 AC 67 ms
71,300 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 237 ms
90,724 KB
testcase_10 AC 178 ms
85,916 KB
testcase_11 AC 186 ms
86,036 KB
testcase_12 AC 613 ms
107,332 KB
testcase_13 AC 610 ms
107,352 KB
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):
    temp = (n - idx) * (n - idx + 1) // 2
    # print(idx, temp)
    ans = max(ans, temp - (2 * (i + 1)))
print(max(0, ans))
0