結果

問題 No.396 クラス替え
ユーザー ryoo14ryoo14
提出日時 2016-12-01 14:37:07
言語 Ruby
(3.4.1)
結果
MLE  
実行時間 -
コード長 490 bytes
コンパイル時間 371 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 235,008 KB
最終ジャッジ日時 2024-11-27 15:46:03
合計ジャッジ時間 26,133 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 RE * 2 TLE * 3 MLE * 12
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:21: warning: assigned but unused variable - students
Syntax OK

ソースコード

diff #

def class_div(a,n,m,f)
  if f then
    1.upto(n) do |i|
      a << i
    end
  else
    n.downto(1) do |i|
      a << i
    end
  end

  if a.size >= m then
    a
  elsif f then
    class_div(a,n,m,false)
  else
    class_div(a,n,m,true)
  end
end

students, classes = gets.split.map(&:to_i)
hanako, taro = gets.split.map(&:to_i)

max = hanako > taro ? hanako : taro

arr = []
arr = class_div(arr, classes, max, true)

if arr[hanako-1] == arr[taro-1] then
  puts "YES"
else
  puts "NO"
end
0