結果

問題 No.1021 Children in Classrooms
ユーザー DakatanDakatan
提出日時 2020-04-11 01:47:06
言語 Ruby
(3.3.0)
結果
AC  
実行時間 319 ms / 2,000 ms
コード長 327 bytes
コンパイル時間 135 ms
コンパイル使用メモリ 11,440 KB
実行使用メモリ 42,876 KB
最終ジャッジ日時 2023-10-14 12:29:28
合計ジャッジ時間 5,527 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
15,140 KB
testcase_01 AC 76 ms
15,064 KB
testcase_02 AC 71 ms
15,224 KB
testcase_03 AC 71 ms
15,140 KB
testcase_04 AC 74 ms
15,132 KB
testcase_05 AC 74 ms
15,168 KB
testcase_06 AC 71 ms
15,332 KB
testcase_07 AC 72 ms
15,512 KB
testcase_08 AC 73 ms
15,508 KB
testcase_09 AC 319 ms
42,428 KB
testcase_10 AC 306 ms
42,600 KB
testcase_11 AC 311 ms
42,500 KB
testcase_12 AC 309 ms
42,500 KB
testcase_13 AC 306 ms
42,640 KB
testcase_14 AC 308 ms
42,400 KB
testcase_15 AC 291 ms
41,200 KB
testcase_16 AC 267 ms
41,132 KB
testcase_17 AC 280 ms
41,268 KB
testcase_18 AC 314 ms
42,876 KB
testcase_19 AC 165 ms
28,272 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

_n, _m = gets.chomp.split(' ').map(&:to_i)
arr = gets.chomp.split(' ').map(&:to_i)
ss = gets.chomp.split('')
ss.each do |s|
  if s == 'L'
    a1 = arr.shift
    a2 = arr.shift
    arr.unshift(a1 + a2)
    arr.push(0)
  else
    a1 = arr.pop
    a2 = arr.pop
    arr.push(a1 + a2)
    arr.unshift(0)
  end
end
puts arr.join(' ')
0