結果

問題 No.2372 既視感
ユーザー siman
提出日時 2023-07-14 06:25:59
言語 Ruby
(3.4.1)
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 672 bytes
コンパイル時間 650 ms
コンパイル使用メモリ 7,296 KB
実行使用メモリ 12,544 KB
最終ジャッジ日時 2024-09-15 14:46:05
合計ジャッジ時間 5,205 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:14: warning: assigned but unused variable - j
Syntax OK

ソースコード

diff #

N, K, Q = gets.split.map(&:to_i)

A = Hash.new
idx = 0

Q.times do
  t = gets.to_i

  if t == 1
    s = gets.chomp
    A[s] = idx
    idx += 1
  else
    j = [1, A.size - N + 1].max
    remain = 60
    cnt = 0
    solved = []
    problems = []
    6.times do
      t, d = gets.chomp.split
      d = d.to_i
      problems << [t, d]
    end

    problems.each do |t, d|
      time = d

      if A[t] && idx - A[t] <= N
        time = K if time > K
      end

      if remain >= time
        remain -= time
        cnt += 1
        solved << t
      else
        break
      end
    end

    solved.each do |t|
      A[t] = idx
      idx += 1
    end

    puts cnt
  end
end
0