結果

問題 No.1687 What the Heck?
ユーザー tcltk
提出日時 2021-09-30 05:14:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 659 ms / 2,000 ms
コード長 593 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 82,484 KB
実行使用メモリ 125,604 KB
最終ジャッジ日時 2024-07-17 08:06:57
合計ジャッジ時間 7,700 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# from typing import *

import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq


def input():
    return sys.stdin.readline()[:-1]


# sys.setrecursionlimit(1000000)

# _INPUT = """3
# 3 1 2

# """
# sys.stdin = io.StringIO(_INPUT)

INF = 10**10

def solve(N, P):
    L = [(P[i], i+1) for i in range(N)]
    L.sort()
    s = 0
    ans = 0
    for p, i in L:
        score = s - i
        ans = max(ans, score)
        s += i

    return ans

N = int(input())
P = list(map(int, input().split()))
print(solve(N, P))
0