結果
| 問題 |
No.1021 Children in Classrooms
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-11-06 15:44:37 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 322 ms / 2,000 ms |
| コード長 | 680 bytes |
| コンパイル時間 | 460 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 40,448 KB |
| 最終ジャッジ日時 | 2024-11-07 13:03:09 |
| 合計ジャッジ時間 | 6,188 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
コンパイルメッセージ
Syntax OK
ソースコード
N, M = gets.split(" ").map{|s| s.to_i}
a = gets.split(" ").map{|s| s.to_i}
S = gets.strip.split("")
lindex = 0
rindex = N-1
ln = rn = 1
S.each {|c|
if c == "L" then
ln += 1 if lindex == 0 and ln < N
lindex -= 1 if lindex > 0
rindex -= 1 if rindex > 0
else
rn += 1 if rindex == N-1 and rn < N
rindex += 1 if rindex < N - 1
lindex += 1 if lindex < N - 1
end
}
ans = ""
ans += "0 " * lindex
if rindex == lindex then
ans += a.sum.to_s
elsif ln + rn == N then
ans += a[0, ln].sum.to_s + " " + a[N-rn, rn].sum.to_s
else
ans += a[0, ln].sum.to_s + + " " + a[ln,N-ln-rn].map{|i| i.to_s}.join(" ") + " " + a[N-rn, rn].sum.to_s
end
ans += " 0" * (N-1-rindex)
puts ans