Submission #18926690
Source Code Expand
Copy
defmodule Main do
def main do
[n, m, t] = IO.read(:line) |> String.trim() |> String.split(" ") |> Enum.map(&String.to_integer/1)
list =
1..m
|> Enum.reduce([], fn _, acc ->
line = IO.read(:line) |> String.trim() |> String.split(" ") |> Enum.map(&String.to_integer/1)
[line | acc]
end)
solve(n, m, t, list) |> IO.puts()
end
def solve(n, m, t, list) do
[[t, t] | list]
|> Enum.reverse()
|> Enum.reduce_while([n, 0], fn p, acc ->
rem = Enum.at(acc, 0) - (Enum.at(p, 0) - Enum.at(acc, 1))
if rem > 0 do
charge = Enum.at(p, 1) - Enum.at(p, 0)
{:cont, [min(n, rem + charge), Enum.at(p, 1)]}
else
{:halt, rem}
end
end)
|> ans()
end
def ans(n) when n > 0, do: "Yes"
def ans(_), do: "No"
end
Submission Info
Submission Time |
|
Task |
B - Smartphone Addiction |
User |
akht |
Language |
Elixir (1.10.2) |
Score |
200 |
Code Size |
843 Byte |
Status |
AC |
Exec Time |
436 ms |
Memory |
30696 KB |
Compile Error
warning: variable "m" is unused (if the variable is not meant to be used, prefix it with an underscore)
Main.ex:14: Main.solve/4
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
200 / 200 |
Status |
|
|
Set Name |
Test Cases |
Sample |
sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_05.txt |
All |
handmade_00.txt, handmade_01.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_05.txt |
Case Name |
Status |
Exec Time |
Memory |
handmade_00.txt |
AC |
413 ms |
30380 KB |
handmade_01.txt |
AC |
401 ms |
30636 KB |
random_00.txt |
AC |
408 ms |
30696 KB |
random_01.txt |
AC |
408 ms |
30392 KB |
random_02.txt |
AC |
404 ms |
30460 KB |
random_03.txt |
AC |
414 ms |
30476 KB |
random_04.txt |
AC |
403 ms |
30320 KB |
random_05.txt |
AC |
424 ms |
30440 KB |
random_06.txt |
AC |
402 ms |
30448 KB |
random_07.txt |
AC |
404 ms |
30488 KB |
random_08.txt |
AC |
436 ms |
30308 KB |
random_09.txt |
AC |
407 ms |
30520 KB |
random_10.txt |
AC |
402 ms |
30552 KB |
random_11.txt |
AC |
406 ms |
30396 KB |
random_12.txt |
AC |
410 ms |
30376 KB |
random_13.txt |
AC |
408 ms |
30520 KB |
sample_01.txt |
AC |
395 ms |
30424 KB |
sample_02.txt |
AC |
425 ms |
30464 KB |
sample_03.txt |
AC |
427 ms |
30568 KB |
sample_04.txt |
AC |
404 ms |
30572 KB |
sample_05.txt |
AC |
399 ms |
30512 KB |