結果

問題 No.1095 Smallest Kadomatsu Subsequence
ユーザー hirofumi9991hirofumi9991
提出日時 2020-06-27 02:11:03
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 400 bytes
コンパイル時間 137 ms
コンパイル使用メモリ 10,784 KB
実行使用メモリ 30,352 KB
最終ジャッジ日時 2023-09-18 15:14:22
合計ジャッジ時間 5,409 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,788 KB
testcase_01 AC 15 ms
7,852 KB
testcase_02 AC 16 ms
7,856 KB
testcase_03 AC 16 ms
7,796 KB
testcase_04 WA -
testcase_05 AC 15 ms
7,792 KB
testcase_06 AC 15 ms
7,832 KB
testcase_07 AC 15 ms
7,828 KB
testcase_08 WA -
testcase_09 AC 16 ms
7,856 KB
testcase_10 WA -
testcase_11 AC 16 ms
7,840 KB
testcase_12 WA -
testcase_13 AC 32 ms
9,288 KB
testcase_14 AC 32 ms
9,376 KB
testcase_15 WA -
testcase_16 AC 33 ms
9,252 KB
testcase_17 WA -
testcase_18 AC 32 ms
9,236 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 32 ms
9,292 KB
testcase_23 AC 346 ms
30,352 KB
testcase_24 AC 349 ms
29,840 KB
testcase_25 AC 355 ms
29,892 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 247 ms
30,284 KB
testcase_29 AC 270 ms
30,304 KB
testcase_30 AC 297 ms
29,840 KB
testcase_31 AC 306 ms
29,844 KB
testcase_32 AC 306 ms
29,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))
S = [0] * (N+1)
S[-1] = float('inf')
for i, a in enumerate(A[::-1]):
    S[N-1-i] = min(a, S[N - i])

ans = float('inf')
first = A[0]
Done = set()
for i, a in enumerate(A[1:-1]):
    if (first - a) * (S[i+1] - a) > 0:
        ans = min(ans, first + S[i+1] + a)
    if first > a:
        first = a


if ans == float('inf'):
    ans = -1
print(ans)
0