結果

問題 No.1021 Children in Classrooms
コンテスト
ユーザー terasa
提出日時 2022-06-03 14:52:49
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 116 ms / 2,000 ms
コード長 1,039 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 110 ms
コンパイル使用メモリ 85,536 KB
実行使用メモリ 115,484 KB
最終ジャッジ日時 2026-04-09 10:16:54
合計ジャッジ時間 3,302 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
import pypyjit
import itertools
import heapq
import math
from collections import deque, defaultdict
import bisect

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
pypyjit.set_param('max_unroll_recursion=-1')


def index_lt(a, x):
    'return largest index s.t. A[i] < x or -1 if it does not exist'
    return bisect.bisect_left(a, x) - 1


def index_le(a, x):
    'return largest index s.t. A[i] <= x or -1 if it does not exist'
    return bisect.bisect_right(a, x) - 1


def index_gt(a, x):
    'return smallest index s.t. A[i] > x or len(a) if it does not exist'
    return bisect.bisect_right(a, x)


def index_ge(a, x):
    'return smallest index s.t. A[i] >= x or len(a) if it does not exist'
    return bisect.bisect_left(a, x)


N, M = map(int, input().split())
A = list(map(int, input().split()))
S = input()[:-1]

dq = deque(A)
for c in S:
    if c == 'L':
        v = dq.popleft()
        dq[0] += v
        dq.append(0)
    else:
        v = dq.pop()
        dq[-1] += v
        dq.appendleft(0)
print(*dq)
0