結果

問題 No.1687 What the Heck?
ユーザー momoyuu
提出日時 2022-03-27 16:32:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 478 bytes
コンパイル時間 181 ms
コンパイル使用メモリ 82,120 KB
実行使用メモリ 106,448 KB
最終ジャッジ日時 2024-11-06 10:15:22
合計ジャッジ時間 2,311 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    import sys
    input = sys.stdin.readline
    
    N = int(input())
    P = list(map(int,input().split()))
    count = 0
    sum = [0 for _ in range(N)]
    for i in range(N):
        sum[P[i]-1] = i + 1
    for i in range(1,N):
        sum[i] += sum[i-1]

    for i in range(N):
        if i == 0:
            count = max(count,0)
            continue
        count = max(count,sum[i-1]-(sum[i]-sum[i-1]))
    print(count)

if __name__ == '__main__':
    main()
0