結果

問題 No.1095 Smallest Kadomatsu Subsequence
ユーザー hirofumi9991hirofumi9991
提出日時 2020-06-27 02:02:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 356 bytes
コンパイル時間 233 ms
コンパイル使用メモリ 10,676 KB
実行使用メモリ 34,640 KB
最終ジャッジ日時 2023-09-18 14:56:07
合計ジャッジ時間 6,958 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
12,320 KB
testcase_01 AC 17 ms
7,880 KB
testcase_02 AC 16 ms
7,800 KB
testcase_03 AC 16 ms
7,788 KB
testcase_04 AC 16 ms
7,748 KB
testcase_05 AC 16 ms
7,848 KB
testcase_06 AC 16 ms
7,800 KB
testcase_07 AC 17 ms
7,788 KB
testcase_08 AC 16 ms
7,856 KB
testcase_09 AC 16 ms
7,856 KB
testcase_10 AC 17 ms
7,764 KB
testcase_11 AC 15 ms
7,792 KB
testcase_12 AC 16 ms
7,748 KB
testcase_13 AC 27 ms
9,188 KB
testcase_14 AC 28 ms
9,188 KB
testcase_15 AC 27 ms
9,116 KB
testcase_16 AC 27 ms
9,276 KB
testcase_17 AC 27 ms
9,244 KB
testcase_18 AC 27 ms
9,084 KB
testcase_19 AC 27 ms
9,140 KB
testcase_20 AC 28 ms
9,088 KB
testcase_21 AC 27 ms
9,140 KB
testcase_22 AC 27 ms
9,248 KB
testcase_23 AC 247 ms
30,200 KB
testcase_24 AC 244 ms
29,844 KB
testcase_25 AC 242 ms
29,928 KB
testcase_26 AC 238 ms
30,216 KB
testcase_27 AC 239 ms
29,944 KB
testcase_28 TLE -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))

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


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