結果

問題 No.1687 What the Heck?
ユーザー ygd.ygd.
提出日時 2021-09-24 21:44:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 120 ms / 2,000 ms
コード長 421 bytes
コンパイル時間 279 ms
コンパイル使用メモリ 87,080 KB
実行使用メモリ 106,320 KB
最終ジャッジ日時 2023-09-18 21:03:23
合計ジャッジ時間 3,324 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,476 KB
testcase_01 AC 74 ms
71,220 KB
testcase_02 AC 74 ms
71,444 KB
testcase_03 AC 75 ms
71,380 KB
testcase_04 AC 75 ms
71,276 KB
testcase_05 AC 74 ms
71,336 KB
testcase_06 AC 74 ms
71,348 KB
testcase_07 AC 93 ms
85,092 KB
testcase_08 AC 97 ms
89,960 KB
testcase_09 AC 92 ms
85,060 KB
testcase_10 AC 87 ms
81,728 KB
testcase_11 AC 89 ms
81,924 KB
testcase_12 AC 118 ms
106,288 KB
testcase_13 AC 119 ms
106,116 KB
testcase_14 AC 119 ms
106,232 KB
testcase_15 AC 120 ms
106,320 KB
testcase_16 AC 119 ms
106,212 KB
testcase_17 AC 81 ms
76,208 KB
testcase_18 AC 116 ms
106,312 KB
testcase_19 AC 79 ms
76,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input()); INF = pow(10,18)
    P = list(map(int,input().split()))
    L = [-1]*N
    for i,p in enumerate(P):
        L[p-1] = i+1
    #print(L)
    plus = 0
    minus = 0
    ans = 0
    for i in range(N-1):
        plus += L[i]
        minus = L[i+1]
        ans = max(ans, plus - minus)
    print(ans)        

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