結果

問題 No.1031 いたずら好きなお姉ちゃん
ユーザー MNGOFMNGOF
提出日時 2020-04-27 00:23:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
MLE  
実行時間 -
コード長 1,095 bytes
コンパイル時間 78 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 544,852 KB
最終ジャッジ日時 2024-04-29 19:59:39
合計ジャッジ時間 15,967 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
16,000 KB
testcase_01 AC 28 ms
10,752 KB
testcase_02 AC 29 ms
10,624 KB
testcase_03 AC 43 ms
11,264 KB
testcase_04 AC 47 ms
11,264 KB
testcase_05 AC 45 ms
11,392 KB
testcase_06 AC 44 ms
11,136 KB
testcase_07 AC 41 ms
11,264 KB
testcase_08 AC 43 ms
11,264 KB
testcase_09 AC 40 ms
11,136 KB
testcase_10 AC 43 ms
11,136 KB
testcase_11 AC 354 ms
21,960 KB
testcase_12 AC 362 ms
23,804 KB
testcase_13 AC 444 ms
26,156 KB
testcase_14 AC 372 ms
23,548 KB
testcase_15 AC 431 ms
26,568 KB
testcase_16 AC 364 ms
21,736 KB
testcase_17 AC 420 ms
23,852 KB
testcase_18 AC 391 ms
23,880 KB
testcase_19 AC 416 ms
24,736 KB
testcase_20 AC 439 ms
24,620 KB
testcase_21 AC 389 ms
24,592 KB
testcase_22 AC 361 ms
22,124 KB
testcase_23 AC 380 ms
26,284 KB
testcase_24 AC 420 ms
22,992 KB
testcase_25 AC 454 ms
24,196 KB
testcase_26 AC 399 ms
24,044 KB
testcase_27 AC 383 ms
22,764 KB
testcase_28 AC 422 ms
23,800 KB
testcase_29 AC 445 ms
26,960 KB
testcase_30 AC 433 ms
25,296 KB
testcase_31 AC 444 ms
25,464 KB
testcase_32 AC 446 ms
24,188 KB
testcase_33 AC 454 ms
27,856 KB
testcase_34 AC 83 ms
22,224 KB
testcase_35 MLE -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(area):
    if len(area) <= 1:
        return 0
    selected_ind = [0] * len(area)
    max_ind = area.index(max(area))
    min_ind = max_ind
    for i in reversed(range(max_ind)):
        if area[min_ind] > area[i]:
            min_ind = i
            selected_ind[min_ind] = 1
    min_ind = max_ind
    for i in range(max_ind+1, len(area)):
        if area[min_ind] > area[i]:
            min_ind = i
            selected_ind[min_ind] = 1
    count = sum(selected_ind)
    tmp_sum = sum(selected_ind[0:max_ind])
    tmp_len = len(selected_ind[0:max_ind])
    if tmp_len == tmp_sum and tmp_len > 2:
        count += int(tmp_sum * (tmp_sum - 1) / 2)
    else:
        count += solve(area[0:max_ind])
    tmp_sum = sum(selected_ind[max_ind + 1: len(area)])
    tmp_len = len(selected_ind[max_ind + 1: len(area)])
    if tmp_len == tmp_sum and tmp_len > 2:
        count += int(tmp_sum * (tmp_sum - 1) / 2)
    else:
        count += solve(area[max_ind + 1: len(area)])
    return int(count)
    

N = int(input())
data = input().split()
Input = [int(s) for s in data]

print(solve(Input))
0