結果

問題 No.1031 いたずら好きなお姉ちゃん
ユーザー MNGOFMNGOF
提出日時 2020-04-26 19:50:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,282 bytes
コンパイル時間 147 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 54,744 KB
最終ジャッジ日時 2024-04-28 23:58:20
合計ジャッジ時間 66,937 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 547 ms
49,888 KB
testcase_01 AC 540 ms
43,992 KB
testcase_02 AC 539 ms
44,124 KB
testcase_03 AC 607 ms
43,872 KB
testcase_04 AC 606 ms
44,248 KB
testcase_05 AC 599 ms
44,124 KB
testcase_06 AC 604 ms
44,004 KB
testcase_07 AC 595 ms
44,124 KB
testcase_08 AC 598 ms
43,876 KB
testcase_09 AC 695 ms
43,868 KB
testcase_10 AC 607 ms
44,128 KB
testcase_11 AC 2,043 ms
45,784 KB
testcase_12 AC 2,030 ms
46,168 KB
testcase_13 AC 2,417 ms
48,736 KB
testcase_14 AC 2,105 ms
45,916 KB
testcase_15 AC 2,272 ms
48,732 KB
testcase_16 AC 2,028 ms
45,664 KB
testcase_17 AC 2,275 ms
48,604 KB
testcase_18 AC 2,193 ms
48,220 KB
testcase_19 AC 2,290 ms
48,232 KB
testcase_20 AC 2,407 ms
48,600 KB
testcase_21 AC 2,212 ms
48,228 KB
testcase_22 AC 2,045 ms
45,796 KB
testcase_23 AC 2,066 ms
45,784 KB
testcase_24 AC 2,298 ms
48,356 KB
testcase_25 AC 2,382 ms
48,484 KB
testcase_26 AC 2,234 ms
48,220 KB
testcase_27 AC 2,147 ms
46,056 KB
testcase_28 AC 2,405 ms
49,340 KB
testcase_29 AC 2,383 ms
48,992 KB
testcase_30 AC 2,435 ms
49,116 KB
testcase_31 AC 2,410 ms
49,512 KB
testcase_32 AC 2,384 ms
48,860 KB
testcase_33 AC 2,408 ms
49,116 KB
testcase_34 TLE -
testcase_35 -- -
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 #

import numpy as np


def solve_max(area):
    next_area = np.array(area)
    count = 0
    while True:
        max_ind = np.argmax(next_area)
        min_ind = np.argmin(next_area)
        if max_ind == min_ind:
            break
        next_area = next_area[0:min_ind] if max_ind < min_ind else next_area[min_ind + 1: next_area.shape[0]]
        count += 1
    return count


def solve_min(area):
    next_area = np.array(area)
    count = 0
    while True:
        max_ind = np.argmax(next_area)
        min_ind = np.argmin(next_area)
        if max_ind == min_ind:
            break
        next_area = next_area[0:max_ind] if max_ind > min_ind else next_area[max_ind + 1: next_area.shape[0]]
        count += 1
    return count


def solve(area):
    if area.shape[0] <= 1:
        return 0
    count = solve_max(area)
    count += solve_min(area) - 1
    max_ind = np.argmax(area)
    min_ind = np.argmin(area)
    left_ind = min_ind if min_ind < max_ind else max_ind
    right_ind = min_ind if min_ind > max_ind else max_ind
    count += solve(area[0:left_ind])
    count += solve(area[left_ind+1: right_ind])
    count += solve(area[right_ind+1:area.shape[0]])
    return count


N = int(input())
input_np = np.array(input().split()).astype(np.int32)

print(solve(input_np))
0