AtCoder Beginner Contest 005

Submission #1591081

Source codeソースコード

T = gets.to_i
N = gets.to_i
AS = gets.split.map(&:to_i)
M = gets.to_i
BS = gets.split.map(&:to_i)

# たこ焼きの一覧(焼けた時刻)
takos = []
1.upto([AS.last, BS.last].max) do |t|
  while AS.first == t
    # 焼けた
    AS.shift
    takos.push(t)
  end
  #p t: t, takos: takos
  while BS.first == t
    # 客が来た
    BS.shift
    loop do
      if takos.empty?
        puts "no"; exit
      end
      if takos.first >= t-T
        # 十分新しいのがあるので売る
        sell = takos.shift
        #p sell: sell
        break
      else
        # 古すぎるので廃棄処分する
        garbage = takos.shift
        #p garbage: garbage
      end
    end
  end
end
puts "yes"

Submission

Task問題 C - おいしいたこ焼きの売り方
User nameユーザ名 Yutaka Hara
Created time投稿日時
Language言語 Ruby (2.3.3)
Status状態 AC
Score得点 100
Source lengthソースコード長 742 Byte
File nameファイル名
Exec time実行時間 7 ms
Memory usageメモリ使用量 1788 KB

Compiler messageコンパイルメッセージ

./Main.rb:25: warning: assigned but unused variable - sell
./Main.rb:30: warning: assigned but unused variable - garbage

Test case

Set

Set name Score得点 / Max score Cases
All 100 / 100 rand0.txt,rand1.txt,rand10.txt,rand11.txt,rand12.txt,rand13.txt,rand14.txt,rand15.txt,rand16.txt,rand17.txt,rand18.txt,rand19.txt,rand2.txt,rand20.txt,rand21.txt,rand22.txt,rand23.txt,rand24.txt,rand25.txt,rand26.txt,rand27.txt,rand28.txt,rand29.txt,rand3.txt,rand4.txt,rand5.txt,rand6.txt,rand7.txt,rand8.txt,rand9.txt,s1.txt,s2.txt,s3.txt,s4.txt,s5.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
rand0.txt AC 7 ms 1788 KB
rand1.txt AC 7 ms 1788 KB
rand10.txt AC 7 ms 1788 KB
rand11.txt AC 7 ms 1788 KB
rand12.txt AC 7 ms 1788 KB
rand13.txt AC 7 ms 1788 KB
rand14.txt AC 7 ms 1788 KB
rand15.txt AC 7 ms 1788 KB
rand16.txt AC 7 ms 1788 KB
rand17.txt AC 7 ms 1788 KB
rand18.txt AC 7 ms 1788 KB
rand19.txt AC 7 ms 1788 KB
rand2.txt AC 7 ms 1788 KB
rand20.txt AC 7 ms 1788 KB
rand21.txt AC 7 ms 1788 KB
rand22.txt AC 7 ms 1788 KB
rand23.txt AC 7 ms 1788 KB
rand24.txt AC 7 ms 1788 KB
rand25.txt AC 7 ms 1788 KB
rand26.txt AC 7 ms 1788 KB
rand27.txt AC 7 ms 1788 KB
rand28.txt AC 7 ms 1788 KB
rand29.txt AC 7 ms 1788 KB
rand3.txt AC 7 ms 1788 KB
rand4.txt AC 7 ms 1788 KB
rand5.txt AC 7 ms 1788 KB
rand6.txt AC 7 ms 1788 KB
rand7.txt AC 7 ms 1788 KB
rand8.txt AC 7 ms 1788 KB
rand9.txt AC 7 ms 1788 KB
s1.txt AC 7 ms 1788 KB
s2.txt AC 7 ms 1788 KB
s3.txt AC 7 ms 1788 KB
s4.txt AC 7 ms 1788 KB
s5.txt AC 7 ms 1788 KB