結果
問題 |
No.1021 Children in Classrooms
|
ユーザー |
|
提出日時 | 2022-05-17 22:00:16 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,109 bytes |
コンパイル時間 | 129 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 30,696 KB |
最終ジャッジ日時 | 2024-09-15 19:24:08 |
合計ジャッジ時間 | 4,568 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 7 RE * 10 |
ソースコード
n,m = map(int, input().split()) a = list(map(int, input().split())) s = input() l = 0 r = 0 L = 0 R = 0 count = 0 count_ex = 0 ex_sw = True for i in range(m): if s[i] == "L": l += 1 count -= 1 count_ex -= 1 if L < l - r: L = l - r count = 0 if count_ex < 0: count_ex = 0 elif s[i] == "R": r += 1 count += 1 count_ex += 1 if R < r - l: R = r - l if count_ex > n - 1: count_ex = n - 1 if L + R == n - 1 and ex_sw: ex_sw = False if s[i] == "L": count_ex = 0 elif s[i] == "R": count_ex = n - 1 if ex_sw: ans_L = 0 ans_R = 0 for i in range(L + 1): ans_L += a[i] for i in range(n - R - 1, n): ans_R += a[i] ans = [0] * count ans.append(ans_L) if a[L + 1: n - R - 1]: ans.append(*a[L + 1: n - R - 1]) ans.append(ans_R) print(*ans) else: ans_sum = 0 for i in a: ans_sum += i ans = [0] * n ans[count_ex] = ans_sum print(*ans)