結果
問題 | No.1031 いたずら好きなお姉ちゃん |
ユーザー | MNGOF |
提出日時 | 2020-04-27 00:21:56 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,172 bytes |
コンパイル時間 | 219 ms |
コンパイル使用メモリ | 82,216 KB |
実行使用メモリ | 103,040 KB |
最終ジャッジ日時 | 2024-04-29 19:57:26 |
合計ジャッジ時間 | 16,209 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
57,472 KB |
testcase_01 | AC | 39 ms
51,712 KB |
testcase_02 | AC | 39 ms
52,096 KB |
testcase_03 | AC | 104 ms
76,672 KB |
testcase_04 | AC | 126 ms
77,832 KB |
testcase_05 | AC | 117 ms
76,672 KB |
testcase_06 | AC | 107 ms
77,172 KB |
testcase_07 | AC | 114 ms
76,928 KB |
testcase_08 | AC | 118 ms
77,440 KB |
testcase_09 | AC | 112 ms
77,148 KB |
testcase_10 | AC | 106 ms
76,912 KB |
testcase_11 | AC | 315 ms
92,384 KB |
testcase_12 | AC | 376 ms
95,428 KB |
testcase_13 | AC | 435 ms
103,040 KB |
testcase_14 | AC | 385 ms
97,020 KB |
testcase_15 | AC | 350 ms
97,320 KB |
testcase_16 | AC | 329 ms
95,296 KB |
testcase_17 | AC | 389 ms
97,400 KB |
testcase_18 | AC | 397 ms
97,280 KB |
testcase_19 | AC | 367 ms
100,480 KB |
testcase_20 | AC | 362 ms
97,536 KB |
testcase_21 | AC | 344 ms
95,952 KB |
testcase_22 | AC | 372 ms
94,108 KB |
testcase_23 | AC | 334 ms
97,764 KB |
testcase_24 | AC | 400 ms
97,360 KB |
testcase_25 | AC | 420 ms
98,260 KB |
testcase_26 | AC | 412 ms
97,408 KB |
testcase_27 | AC | 323 ms
94,384 KB |
testcase_28 | AC | 415 ms
97,220 KB |
testcase_29 | AC | 407 ms
99,968 KB |
testcase_30 | AC | 361 ms
99,572 KB |
testcase_31 | AC | 427 ms
100,148 KB |
testcase_32 | AC | 365 ms
98,108 KB |
testcase_33 | AC | 396 ms
100,852 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 | -- | - |
ソースコード
def solve(area): next_area = list(area) selected_ind = [0] * len(area) if len(next_area) <= 1: return 0 elif len(next_area) == 2: return 1 while True: max_ind = next_area.index(max(next_area)) min_ind = next_area.index(min(next_area)) if max_ind == min_ind: break selected_ind[area.index(next_area[min_ind])] = 1 next_area = next_area[0:min_ind] if max_ind < min_ind else next_area[min_ind + 1: len(next_area)] max_ind = area.index(max(area)) 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 += 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 += 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))