結果

問題 No.1031 いたずら好きなお姉ちゃん
ユーザー MNGOF
提出日時 2020-04-26 20:24:38
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 845 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 98,668 KB
最終ジャッジ日時 2024-11-18 07:46:45
合計ジャッジ時間 141,509 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33 TLE * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np


def solve(area):
    next_area = area
    if next_area.shape[0] <= 1:
        return 0
    elif next_area.shape[0] == 2:
        return 1
    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
    max_ind = np.argmax(area)
    if max_ind == 2:
        count += 1
    elif max_ind > 2:
        count += solve(area[0:max_ind])

    if (area.shape[0] - max_ind) == 3:
        count += 1
    elif (area.shape[0] - max_ind) > 3:
        count += solve(area[max_ind + 1: area.shape[0]])
    return count

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

print(solve(input_np))
0