結果
| 問題 | 
                            No.1021 Children in Classrooms
                             | 
                    
| コンテスト | |
| ユーザー | 
                             学ぶマン
                         | 
                    
| 提出日時 | 2025-09-05 21:27:12 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,123 bytes | 
| コンパイル時間 | 191 ms | 
| コンパイル使用メモリ | 82,712 KB | 
| 実行使用メモリ | 107,000 KB | 
| 最終ジャッジ日時 | 2025-09-05 21:27:19 | 
| 合計ジャッジ時間 | 3,576 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 4 WA * 13 | 
ソースコード
import sys, math
sys.setrecursionlimit(10**8)
sys.set_int_max_str_digits(0)
INF = 10**18
MOD = 998244353
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import product, combinations, permutations, groupby, accumulate
N, M = map(int, input().split())
A = list(map(int, input().split()))
S = input()
pos = [0]
# 二人だけ位置を追う
a1, aN = 0, N - 1
for s in S:
    if s == 'L':
        pos.append(pos[-1] - 1)
        if a1 != 0:
            a1 -= 1
        if aN != 0:
            aN -= 1
    else:
        pos.append(pos[-1] + 1)
        if a1 != N - 1:
            a1 += 1
        if aN != N - 1:
            aN += 1
left = min(pos)
right = max(pos)
# 最終的な相対位置
memo = pos[-1]
# index: 1 ~ left の数字は a1 にマージ
# index: N - right ~ N - 2 の数字は aN にマージ
ans = [0] * N
ans[a1] += A[0]
ans[aN] += A[-1]
for i in range(1, N - 1):
    if 1 <= i <= left:
        ans[a1] += A[i]
        
    elif N - right <= i <= N - 2:
        ans[aN] += A[i]
    
    else:
        ans[i + memo] += A[i]
print(*ans)
            
            
            
        
            
学ぶマン