結果

問題 No.1687 What the Heck?
コンテスト
ユーザー momoyuu
提出日時 2022-03-27 16:32:53
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 478 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 176 ms
コンパイル使用メモリ 85,316 KB
実行使用メモリ 106,752 KB
最終ジャッジ日時 2026-05-06 14:14:28
合計ジャッジ時間 2,930 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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