結果
問題 | No.1031 いたずら好きなお姉ちゃん |
ユーザー | MNGOF |
提出日時 | 2020-04-27 01:03:31 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,756 bytes |
コンパイル時間 | 405 ms |
コンパイル使用メモリ | 82,028 KB |
実行使用メモリ | 850,600 KB |
最終ジャッジ日時 | 2024-11-19 05:08:32 |
合計ジャッジ時間 | 63,516 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
57,088 KB |
testcase_01 | AC | 39 ms
58,760 KB |
testcase_02 | AC | 40 ms
57,856 KB |
testcase_03 | AC | 130 ms
337,544 KB |
testcase_04 | AC | 122 ms
83,056 KB |
testcase_05 | AC | 120 ms
339,584 KB |
testcase_06 | AC | 117 ms
82,816 KB |
testcase_07 | AC | 122 ms
336,728 KB |
testcase_08 | AC | 121 ms
83,456 KB |
testcase_09 | AC | 125 ms
339,940 KB |
testcase_10 | AC | 110 ms
82,688 KB |
testcase_11 | AC | 371 ms
92,216 KB |
testcase_12 | AC | 362 ms
92,760 KB |
testcase_13 | AC | 386 ms
96,636 KB |
testcase_14 | AC | 365 ms
92,732 KB |
testcase_15 | AC | 383 ms
97,352 KB |
testcase_16 | AC | 366 ms
93,448 KB |
testcase_17 | AC | 371 ms
94,780 KB |
testcase_18 | AC | 372 ms
93,452 KB |
testcase_19 | AC | 393 ms
96,528 KB |
testcase_20 | AC | 384 ms
94,528 KB |
testcase_21 | AC | 390 ms
94,392 KB |
testcase_22 | AC | 359 ms
91,828 KB |
testcase_23 | AC | 376 ms
95,264 KB |
testcase_24 | AC | 383 ms
94,564 KB |
testcase_25 | AC | 391 ms
94,672 KB |
testcase_26 | AC | 383 ms
94,520 KB |
testcase_27 | AC | 368 ms
93,192 KB |
testcase_28 | AC | 389 ms
94,444 KB |
testcase_29 | AC | 391 ms
95,816 KB |
testcase_30 | AC | 389 ms
96,756 KB |
testcase_31 | AC | 396 ms
97,268 KB |
testcase_32 | AC | 383 ms
94,788 KB |
testcase_33 | AC | 402 ms
98,036 KB |
testcase_34 | AC | 64 ms
78,208 KB |
testcase_35 | TLE | - |
testcase_36 | TLE | - |
testcase_37 | TLE | - |
testcase_38 | TLE | - |
testcase_39 | TLE | - |
testcase_40 | TLE | - |
testcase_41 | TLE | - |
testcase_42 | RE | - |
testcase_43 | AC | 2,762 ms
340,004 KB |
testcase_44 | AC | 1,856 ms
444,840 KB |
testcase_45 | AC | 1,844 ms
293,668 KB |
testcase_46 | MLE | - |
testcase_47 | MLE | - |
testcase_48 | MLE | - |
testcase_49 | MLE | - |
testcase_50 | MLE | - |
testcase_51 | AC | 70 ms
78,532 KB |
testcase_52 | AC | 70 ms
78,840 KB |
testcase_53 | AC | 71 ms
78,944 KB |
testcase_54 | AC | 42 ms
52,512 KB |
testcase_55 | AC | 42 ms
58,808 KB |
ソースコード
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: next_left_ind = max_ind if next_left_ind > 0: while area.index(max(area[0:next_left_ind])) == (next_left_ind - 1): count += sum(selected_ind[0:next_left_ind - 1]) next_left_ind -= 1 if next_left_ind < 1: break count += solve(area[0:next_left_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: next_right_ind = max_ind if next_right_ind < len(area) - 1: while area.index(max(area[next_right_ind + 1: len(area)])) == 0: count += sum(selected_ind[next_right_ind + 2: len(area)]) next_right_ind += 1 if next_right_ind > len(area) - 1: break count += solve(area[next_right_ind + 1: len(area)]) return int(count) N = int(input()) data = input().split() Input = [int(s) for s in data] print(solve(Input))