結果
| 問題 |
No.1031 いたずら好きなお姉ちゃん
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-26 22:17:31 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,024 bytes |
| コンパイル時間 | 407 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 98,656 KB |
| 最終ジャッジ日時 | 2024-11-18 13:05:28 |
| 合計ジャッジ時間 | 127,527 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 RE * 20 TLE * 23 |
ソースコード
import numpy as np
def solve(area, selected_ind, flag):
if area.shape[0] <= 1:
return 0
# selected_ind = area*0
max_ind = np.argmax(area)
min_ind = max_ind
if flag == 2:
selected_ind[0: max_ind + 1] = 0
for i in reversed(range(max_ind)):
if selected_ind[i] == 1:
break
if area[min_ind] > area[i]:
min_ind = i
selected_ind[i] = 1
min_ind = max_ind
if flag == 1:
selected_ind[max_ind:area.shape[0]] = 0
for i in range(max_ind+1, area.shape[0]):
if selected_ind[i] == 1:
break
if area[min_ind] > area[i]:
min_ind = i
selected_ind[i] = 1
count = np.sum(selected_ind)
count += solve(area[0:max_ind], selected_ind[0:max_ind], 1)
count += solve(area[max_ind+1:area.shape[0]], selected_ind[max_ind+1:selected_ind.shape[0]], 2)
return count
N = int(input())
input_np = np.array(input().split()).astype(np.int32)
print(solve(input_np, input_np*0, 0))