結果

問題 No.446 ゆきこーだーの雨と雪 (1)
ユーザー nnsniconnsnico
提出日時 2019-05-01 16:25:18
言語 Scala(Beta)
(3.4.0)
結果
AC  
実行時間 946 ms / 2,000 ms
コード長 453 bytes
コンパイル時間 8,248 ms
コンパイル使用メモリ 249,352 KB
実行使用メモリ 62,168 KB
最終ジャッジ日時 2023-09-14 16:17:29
合計ジャッジ時間 25,987 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 923 ms
61,928 KB
testcase_01 AC 928 ms
61,912 KB
testcase_02 AC 908 ms
61,968 KB
testcase_03 AC 928 ms
61,904 KB
testcase_04 AC 929 ms
61,784 KB
testcase_05 AC 937 ms
61,896 KB
testcase_06 AC 946 ms
61,972 KB
testcase_07 AC 935 ms
61,804 KB
testcase_08 AC 923 ms
62,168 KB
testcase_09 AC 927 ms
61,764 KB
testcase_10 AC 935 ms
62,004 KB
testcase_11 AC 919 ms
62,132 KB
testcase_12 AC 929 ms
61,916 KB
testcase_13 AC 944 ms
61,900 KB
testcase_14 AC 936 ms
62,104 KB
testcase_15 AC 933 ms
61,824 KB
testcase_16 AC 912 ms
61,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

object Main extends App {
  val a: String = scala.io.StdIn.readLine()
  val b: String = scala.io.StdIn.readLine()

  val resolveNum = (n: String) =>
    if (n.matches("^(?!(00|0.+))[0-9]{1,5}") && n.toInt <= 12345) {
      Some(n.toInt)
    } else {
      None
  }

  val aIntOpt = resolveNum(a)

  val bIntOpt = resolveNum(b)

  val ans = for {
    a <- aIntOpt
    b <- bIntOpt
  } yield {
    a + b
  }

  println(if (ans.nonEmpty) "OK" else "NG")

}
0