結果
| 問題 |
No.1021 Children in Classrooms
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-10 21:57:52 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 443 ms / 2,000 ms |
| コード長 | 1,031 bytes |
| コンパイル時間 | 174 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 30,824 KB |
| 最終ジャッジ日時 | 2024-09-15 20:18:08 |
| 合計ジャッジ時間 | 5,964 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from collections import deque
from heapq import heapify,heappush,heappop
def main():
n,m = map(int,input().split())
a = list(map(int,input().split()))
s = input()
d = 0
r = 0
l = 0
lk = 0
rk = n - 1
for i in range(m):
if s[i] == 'R':
d += 1
lk = min(lk + 1,n - 1)
rk = min(rk + 1,n - 1)
r = max(r,d)
else:
d -= 1
lk = max(0,lk - 1)
rk = max(0,rk - 1)
l = min(l,d)
l = -l
ans = [0] * n
if r + l >= n - 1:
t = sum(a)
ans[lk] = t
else:
j = lk
for i in range(n):
if i < l + 1:
ans[lk] += a[i]
elif l + 1 <= i < n - r - 1:
j += 1
ans[j] += a[i]
else:
ans[rk] += a[i]
print(*ans)
if __name__ =='__main__':
main()