結果

問題 No.247 線形計画問題もどき
ユーザー ともきともき
提出日時 2015-07-18 05:32:50
言語 Scala(Beta)
(3.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,089 bytes
コンパイル時間 9,675 ms
コンパイル使用メモリ 255,752 KB
実行使用メモリ 72,552 KB
最終ジャッジ日時 2023-09-11 11:49:13
合計ジャッジ時間 41,124 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,041 ms
62,160 KB
testcase_01 AC 940 ms
62,016 KB
testcase_02 TLE -
testcase_03 AC 948 ms
61,880 KB
testcase_04 AC 982 ms
62,328 KB
testcase_05 AC 948 ms
62,004 KB
testcase_06 AC 955 ms
61,876 KB
testcase_07 AC 1,040 ms
62,116 KB
testcase_08 AC 981 ms
63,924 KB
testcase_09 AC 948 ms
61,784 KB
testcase_10 AC 946 ms
61,956 KB
testcase_11 AC 950 ms
62,156 KB
testcase_12 AC 940 ms
62,024 KB
testcase_13 AC 934 ms
62,280 KB
testcase_14 AC 940 ms
61,776 KB
testcase_15 AC 945 ms
62,064 KB
testcase_16 AC 943 ms
62,128 KB
testcase_17 AC 1,020 ms
62,000 KB
testcase_18 AC 985 ms
62,020 KB
testcase_19 AC 1,071 ms
62,088 KB
testcase_20 AC 1,088 ms
66,252 KB
testcase_21 AC 970 ms
62,192 KB
testcase_22 AC 1,013 ms
62,028 KB
testcase_23 AC 979 ms
62,064 KB
testcase_24 AC 1,098 ms
64,024 KB
testcase_25 AC 1,059 ms
62,160 KB
testcase_26 AC 1,032 ms
62,116 KB
testcase_27 AC 1,017 ms
62,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import scala.io.StdIn.readLine
import scala.collection.mutable.PriorityQueue
import scala.annotation.tailrec

// PriorityQueue[Long]()(scala.math.Ordering.Long.reverse)
package net.pushl {
  package number {
    // Prime  (Prime.scala)
    // Number (Number.scala)
  }
  package string {
    // RollingHash (RollingHash.scala)
  }
  object EnRich {
    implicit class AString(val self : String) extends AnyVal {
      def splitToIntArray = self.split(" ").map(_.toInt)
    }
  }
}

import net.pushl.EnRich._
object Main {
  def main(args : Array[String]) : Unit = {
    val c = readLine().toInt
    val n = readLine().toInt
    val a = readLine().splitToIntArray

    val v = Array.fill[Option[Int]](c+1)(None)
    v(0) = Some(0)
    for(i <- a){
      for(k <- i to c){
        (v(k),v(k-i)) match {
          case (Some(a),Some(b)) => v(k) = Some(a min (b+1))
          case (None   ,Some(b)) => v(k) = Some(b+1)
          case (_      ,None   ) => {}
        }
      }
    }
    val out = v(c) match {
        case Some(k) => k
        case None    => -1
      }
    println(out)
  }
}
0