結果

問題 No.2036 Max Middle
ユーザー FromBooskaFromBooska
提出日時 2023-04-18 14:28:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 114 ms / 2,000 ms
コード長 710 bytes
コンパイル時間 406 ms
コンパイル使用メモリ 82,688 KB
実行使用メモリ 120,704 KB
最終ジャッジ日時 2024-04-21 14:23:45
合計ジャッジ時間 3,040 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
51,840 KB
testcase_01 AC 35 ms
51,456 KB
testcase_02 AC 38 ms
51,840 KB
testcase_03 AC 35 ms
51,712 KB
testcase_04 AC 35 ms
51,712 KB
testcase_05 AC 35 ms
51,584 KB
testcase_06 AC 33 ms
51,584 KB
testcase_07 AC 34 ms
51,584 KB
testcase_08 AC 79 ms
95,488 KB
testcase_09 AC 106 ms
104,704 KB
testcase_10 AC 114 ms
112,556 KB
testcase_11 AC 111 ms
113,024 KB
testcase_12 AC 103 ms
120,064 KB
testcase_13 AC 114 ms
112,620 KB
testcase_14 AC 45 ms
60,928 KB
testcase_15 AC 47 ms
61,056 KB
testcase_16 AC 112 ms
112,388 KB
testcase_17 AC 91 ms
112,768 KB
testcase_18 AC 103 ms
116,608 KB
testcase_19 AC 110 ms
120,576 KB
testcase_20 AC 109 ms
120,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 前回の手法で可能ではあるが思いつき不可能なので公式解説の方法に変える
# N項間に不等号を書く、N-1個
# その不等号が<>のときは、><に変わる、それが何回可能か
# スタックはTLEした
# 左から数え上げてみる

N = int(input())
A = list(map(int, input().split()))
signs = []
for i in range(1, N):
    if A[i-1] < A[i]:
        signs.append('<')
    else:
        signs.append('>')
    # equalは制約でない
    
# 2個のdequeはTLEした
# 左から数え上げてみよう

count = 0
subcount = 0
for i in range(N-1):
    if signs[i] == '<':
        subcount += 1
    elif signs[i] == '>':
        count += subcount
print(count)

0