結果

問題 No.1095 Smallest Kadomatsu Subsequence
ユーザー 👑 rin204rin204
提出日時 2020-08-13 08:11:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 574 ms / 2,000 ms
コード長 516 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 32,424 KB
最終ジャッジ日時 2024-04-18 01:18:54
合計ジャッジ時間 8,140 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,880 KB
testcase_01 AC 29 ms
10,624 KB
testcase_02 AC 29 ms
10,752 KB
testcase_03 AC 29 ms
10,624 KB
testcase_04 AC 29 ms
10,880 KB
testcase_05 AC 28 ms
10,752 KB
testcase_06 AC 28 ms
10,752 KB
testcase_07 AC 29 ms
10,624 KB
testcase_08 AC 28 ms
10,624 KB
testcase_09 AC 28 ms
10,624 KB
testcase_10 AC 31 ms
10,624 KB
testcase_11 AC 29 ms
10,752 KB
testcase_12 AC 29 ms
10,752 KB
testcase_13 AC 56 ms
11,904 KB
testcase_14 AC 57 ms
11,904 KB
testcase_15 AC 54 ms
11,904 KB
testcase_16 AC 57 ms
11,904 KB
testcase_17 AC 56 ms
11,776 KB
testcase_18 AC 56 ms
11,776 KB
testcase_19 AC 56 ms
11,904 KB
testcase_20 AC 57 ms
11,904 KB
testcase_21 AC 56 ms
11,904 KB
testcase_22 AC 52 ms
11,904 KB
testcase_23 AC 560 ms
32,292 KB
testcase_24 AC 557 ms
32,424 KB
testcase_25 AC 558 ms
32,420 KB
testcase_26 AC 572 ms
32,416 KB
testcase_27 AC 574 ms
32,424 KB
testcase_28 AC 477 ms
32,288 KB
testcase_29 AC 473 ms
32,284 KB
testcase_30 AC 511 ms
32,420 KB
testcase_31 AC 527 ms
32,296 KB
testcase_32 AC 519 ms
32,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
alst = list(map(int, input().split()))
l = [alst[0]]
for a in alst[1:-2]:
    l.append(min(l[-1], a))
r = [alst[-1]]
for a in alst[2:-1][::-1]:
    r.append(min(r[-1], a))
r = r[::-1]
inf = 10 ** 10
ans = inf
def kado(a, b, c):
    if b == min(a, b, c) or b == max(a, b, c):
        return True
    else:
        return False

for i, a in enumerate(alst[1:-1]):
    rr = r[i]
    ll = l[i]
    if kado(rr, a, ll):
        ans = min(ans, rr + a + ll)
if ans != inf:
    print(ans)
else:
    print(-1)
0