結果

問題 No.1557 Binary Variable
ユーザー tamura2004tamura2004
提出日時 2021-06-26 19:29:27
言語 Crystal
(1.11.2)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 258 bytes
コンパイル時間 23,522 ms
コンパイル使用メモリ 257,900 KB
実行使用メモリ 18,672 KB
最終ジャッジ日時 2023-09-07 15:29:22
合計ジャッジ時間 28,073 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
17,224 KB
testcase_01 AC 65 ms
17,916 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,412 KB
testcase_04 AC 69 ms
16,248 KB
testcase_05 AC 68 ms
16,976 KB
testcase_06 AC 64 ms
15,396 KB
testcase_07 AC 66 ms
15,440 KB
testcase_08 AC 75 ms
16,544 KB
testcase_09 AC 77 ms
16,244 KB
testcase_10 AC 86 ms
16,768 KB
testcase_11 AC 87 ms
17,904 KB
testcase_12 AC 74 ms
16,344 KB
testcase_13 AC 88 ms
17,052 KB
testcase_14 AC 89 ms
16,924 KB
testcase_15 AC 87 ms
16,348 KB
testcase_16 AC 90 ms
18,672 KB
testcase_17 AC 90 ms
16,900 KB
testcase_18 AC 94 ms
17,580 KB
testcase_19 AC 96 ms
16,284 KB
testcase_20 AC 95 ms
17,112 KB
testcase_21 AC 94 ms
17,004 KB
testcase_22 AC 94 ms
17,948 KB
testcase_23 AC 94 ms
17,020 KB
testcase_24 AC 96 ms
17,816 KB
testcase_25 AC 96 ms
16,376 KB
testcase_26 AC 95 ms
16,616 KB
testcase_27 AC 97 ms
18,200 KB
testcase_28 AC 97 ms
16,392 KB
testcase_29 AC 97 ms
18,032 KB
testcase_30 AC 97 ms
18,132 KB
testcase_31 AC 96 ms
16,376 KB
testcase_32 AC 98 ms
18,636 KB
testcase_33 AC 93 ms
17,272 KB
testcase_34 AC 3 ms
4,480 KB
testcase_35 AC 3 ms
4,508 KB
testcase_36 AC 3 ms
4,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = gets.to_s.split.map(&.to_i64)
lr = Array.new(m) do
  l,r = gets.to_s.split.map(&.to_i64)
  { l, r }
end

lr.sort_by!(&.last)

cnt = 0_i64
hi = 0_i64
lr.each do |l, r|
  # 交差する
  if l <= hi
  else
    cnt += 1
    hi = r
  end
end

puts n - cnt
0