結果
| 問題 |
No.1021 Children in Classrooms
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-10 22:04:59 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,582 bytes |
| コンパイル時間 | 329 ms |
| コンパイル使用メモリ | 82,048 KB |
| 実行使用メモリ | 90,240 KB |
| 最終ジャッジ日時 | 2024-09-15 20:25:43 |
| 合計ジャッジ時間 | 4,651 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 3 |
| other | RE * 17 |
ソースコード
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
N, M = MAP()
a = LIST()
S = input()
L_index = 0
R_index = N-1
L_max = 0
R_max = 0
cnt = 0
for s in S:
if s == "R":
cnt += 1
if L_index < N-1:
L_index += 1
if R_index < N-1:
R_index += 1
elif s == "L":
cnt -= 1
if 0 < L_index:
L_index -= 1
if 0 < R_index:
R_index -= 1
if L_max > cnt:
L_max = cnt
if R_max < cnt:
R_max = cnt
L_max = -L_max
# print(L_max, R_max, cnt)
# print(L_index, R_index)
if L_index == R_index:
ans = [0]*N
ans[L_index] = sum(a)
print(*ans)
exit()
if L_max >= N-1:
L_val = sum(a)
else:
L_val = sum(a[:L_max+1])
if R_max >= N-1:
R_val = sum(a)
else:
R_val = sum(a[-R_max-1:])
# print(R_val, L_val)
ans = [0]*N
for i, x in enumerate(a):
if 0 < i-L_max and i+R_max < N-1:
ans[i] = x
elif 0 < i-L_max:
ans[L_index] = L_val
else:
ans[R_index] = R_val
print(*ans)