結果
問題 | No.457 (^^*) |
ユーザー | roaris |
提出日時 | 2019-12-14 18:16:53 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 107 ms / 2,000 ms |
コード長 | 734 bytes |
コンパイル時間 | 332 ms |
コンパイル使用メモリ | 87,036 KB |
実行使用メモリ | 77,172 KB |
最終ジャッジ日時 | 2023-09-10 12:00:03 |
合計ジャッジ時間 | 3,295 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 73 ms
71,204 KB |
testcase_01 | AC | 75 ms
71,172 KB |
testcase_02 | AC | 74 ms
71,404 KB |
testcase_03 | AC | 73 ms
71,208 KB |
testcase_04 | AC | 74 ms
71,000 KB |
testcase_05 | AC | 73 ms
71,196 KB |
testcase_06 | AC | 73 ms
71,460 KB |
testcase_07 | AC | 79 ms
75,168 KB |
testcase_08 | AC | 83 ms
75,580 KB |
testcase_09 | AC | 91 ms
76,132 KB |
testcase_10 | AC | 103 ms
77,020 KB |
testcase_11 | AC | 107 ms
77,172 KB |
testcase_12 | AC | 96 ms
76,956 KB |
testcase_13 | AC | 80 ms
76,084 KB |
testcase_14 | AC | 97 ms
77,052 KB |
testcase_15 | AC | 100 ms
76,908 KB |
testcase_16 | AC | 78 ms
76,200 KB |
testcase_17 | AC | 99 ms
76,932 KB |
testcase_18 | AC | 75 ms
71,396 KB |
testcase_19 | AC | 75 ms
71,388 KB |
ソースコード
from bisect import * S = input() l1, l2 = [], [] acc = [0] for i in range(len(S)): if S[i]=='*': l1.append(i) elif S[i]=='^': l2.append(i) acc.append(acc[-1]+(1 if S[i]=='(' else 0)) ans_left, ans_right = 0, 0 for i in range(len(S)): if S[i]==')': idx = bisect_right(l1, i)-1 if idx!=-1: p = l1[idx] idx = bisect_right(l2, p)-1 if idx>=1: ans_left += acc[l2[idx-1]] idx = bisect_right(l2, i)-1 if idx>=1: p = l2[idx-1] idx = bisect_right(l1, p)-1 if idx!=-1: ans_right += acc[l1[idx]] print(ans_left, ans_right)