結果

問題 No.1205 Eye Drops
ユーザー penqenpenqen
提出日時 2020-12-15 20:06:46
言語 Elixir
(1.16.2)
結果
AC  
実行時間 1,187 ms / 2,000 ms
コード長 821 bytes
コンパイル時間 1,097 ms
コンパイル使用メモリ 56,540 KB
実行使用メモリ 75,236 KB
最終ジャッジ日時 2023-08-30 01:01:49
合計ジャッジ時間 31,368 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 625 ms
49,900 KB
testcase_01 AC 620 ms
49,500 KB
testcase_02 AC 618 ms
49,284 KB
testcase_03 AC 628 ms
50,316 KB
testcase_04 AC 635 ms
49,892 KB
testcase_05 AC 641 ms
49,340 KB
testcase_06 AC 626 ms
49,280 KB
testcase_07 AC 624 ms
49,296 KB
testcase_08 AC 634 ms
50,268 KB
testcase_09 AC 626 ms
49,664 KB
testcase_10 AC 617 ms
50,220 KB
testcase_11 AC 629 ms
49,432 KB
testcase_12 AC 634 ms
49,076 KB
testcase_13 AC 621 ms
49,228 KB
testcase_14 AC 628 ms
49,360 KB
testcase_15 AC 629 ms
49,168 KB
testcase_16 AC 636 ms
49,228 KB
testcase_17 AC 637 ms
49,164 KB
testcase_18 AC 617 ms
49,376 KB
testcase_19 AC 632 ms
49,808 KB
testcase_20 AC 641 ms
50,064 KB
testcase_21 AC 628 ms
49,788 KB
testcase_22 AC 627 ms
49,312 KB
testcase_23 AC 637 ms
49,120 KB
testcase_24 AC 649 ms
49,912 KB
testcase_25 AC 636 ms
49,872 KB
testcase_26 AC 633 ms
49,828 KB
testcase_27 AC 633 ms
49,048 KB
testcase_28 AC 633 ms
49,412 KB
testcase_29 AC 630 ms
49,836 KB
testcase_30 AC 623 ms
49,596 KB
testcase_31 AC 622 ms
49,760 KB
testcase_32 AC 1,167 ms
73,940 KB
testcase_33 AC 1,163 ms
72,460 KB
testcase_34 AC 1,187 ms
74,272 KB
testcase_35 AC 1,168 ms
72,876 KB
testcase_36 AC 1,170 ms
73,440 KB
testcase_37 AC 1,148 ms
75,236 KB
testcase_38 AC 620 ms
49,384 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: variable "i" is unused (if the variable is not meant to be used, prefix it with an underscore)
  Main.exs:5: Main.main/0

ソースコード

diff #

defmodule Main do
  def main do
    [n, m] = IO.read(:line) |> String.trim() |> String.split(" ") |> Enum.map(&String.to_integer/1)

    nm = for i <- 0..(m - 1) do
      IO.read(:line) |> String.trim() |> String.split(" ") |> Enum.map(&String.to_integer/1)
    end
    
    solve(n, m, nm) |> IO.puts
  end
  
  def solve(n, m, matrix) when 1 <= n
    and 0 <= m and m <= 100_000
    and is_list(matrix)
  do
    matrix
    |> Enum.reduce({true, {0, 0}}, fn
      [ti, pi], {true, {ct, cp}} ->
        dt = ti - ct
        dp = abs(cp - pi)
        if dp <= dt and pi < n do
          {true, {ti, pi}}
        else
          false
        end
      _, false ->
        false
    end)
    |> (fn
      false ->
        "No"
      {true, _} ->
        "Yes"
    end).()
  end

  def solve(_n, _m, _matrix), do: "No"
  
end
0