結果

問題 No.1095 Smallest Kadomatsu Subsequence
ユーザー tanon710tanon710
提出日時 2020-07-08 00:35:29
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 528 bytes
コンパイル時間 202 ms
コンパイル使用メモリ 82,288 KB
実行使用メモリ 106,988 KB
最終ジャッジ日時 2024-04-09 22:03:20
合計ジャッジ時間 3,842 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,100 KB
testcase_01 AC 36 ms
52,364 KB
testcase_02 AC 34 ms
54,348 KB
testcase_03 AC 32 ms
53,008 KB
testcase_04 WA -
testcase_05 AC 31 ms
54,052 KB
testcase_06 AC 32 ms
53,760 KB
testcase_07 AC 32 ms
52,812 KB
testcase_08 WA -
testcase_09 AC 31 ms
53,700 KB
testcase_10 WA -
testcase_11 AC 31 ms
53,192 KB
testcase_12 WA -
testcase_13 AC 42 ms
66,600 KB
testcase_14 AC 43 ms
64,416 KB
testcase_15 WA -
testcase_16 AC 43 ms
65,628 KB
testcase_17 WA -
testcase_18 AC 46 ms
66,608 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 41 ms
64,708 KB
testcase_23 AC 105 ms
106,712 KB
testcase_24 AC 106 ms
106,592 KB
testcase_25 AC 104 ms
106,340 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 103 ms
106,844 KB
testcase_29 AC 104 ms
106,604 KB
testcase_30 AC 105 ms
106,720 KB
testcase_31 AC 106 ms
106,720 KB
testcase_32 AC 105 ms
106,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3

import sys
input=sys.stdin.readline

n=int(input())
arr=list(map(int,input().split()))
left_min=[10**18]
for i in range(n):
    left_min.append(min(left_min[-1],arr[i]))
right_min=[10**18]
for i in range(n-1,-1,-1):
    right_min.append(min(right_min[-1],arr[i]))
right_min=right_min[::-1]
ans=10**18
for i in range(1,n-1):
    a,b,c=left_min[i],arr[i],right_min[i]
    if (b<a and b<c) or (b>a and b>c):
        ans=min(ans,a+b+c)
if ans==10**18:
    print(-1)
else:
    print(ans)
0