結果

問題 No.2372 既視感
ユーザー simansiman
提出日時 2023-07-14 06:25:59
言語 Ruby
(3.3.0)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 672 bytes
コンパイル時間 496 ms
コンパイル使用メモリ 11,316 KB
実行使用メモリ 15,348 KB
最終ジャッジ日時 2023-10-13 18:58:58
合計ジャッジ時間 4,820 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
15,048 KB
testcase_01 AC 66 ms
15,076 KB
testcase_02 AC 64 ms
15,032 KB
testcase_03 AC 66 ms
15,180 KB
testcase_04 AC 66 ms
15,164 KB
testcase_05 AC 66 ms
15,180 KB
testcase_06 AC 67 ms
14,984 KB
testcase_07 AC 69 ms
15,164 KB
testcase_08 AC 72 ms
15,288 KB
testcase_09 AC 73 ms
15,136 KB
testcase_10 AC 73 ms
15,068 KB
testcase_11 AC 71 ms
15,336 KB
testcase_12 AC 69 ms
15,244 KB
testcase_13 AC 72 ms
15,292 KB
testcase_14 AC 65 ms
14,968 KB
testcase_15 AC 68 ms
15,228 KB
testcase_16 AC 67 ms
15,136 KB
testcase_17 AC 66 ms
15,212 KB
testcase_18 AC 70 ms
15,092 KB
testcase_19 AC 67 ms
15,076 KB
testcase_20 AC 65 ms
14,960 KB
testcase_21 AC 67 ms
15,136 KB
testcase_22 AC 67 ms
15,100 KB
testcase_23 AC 66 ms
15,348 KB
testcase_24 AC 68 ms
15,252 KB
testcase_25 AC 69 ms
15,280 KB
testcase_26 AC 68 ms
15,200 KB
testcase_27 AC 70 ms
15,248 KB
testcase_28 AC 72 ms
15,216 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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