Submission #856444


Source Code Expand

Copy
class Main {
  import java.{ util => ju }

  import scala.annotation._
  import scala.collection._
  import scala.collection.{ mutable => mu }
  import scala.collection.JavaConverters._
  import scala.math._
  val sc = new ju.Scanner(System.in)

  def solveC() {
    val br = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))
    val n = br.readLine().toInt
    val x = br.readLine().split(" ").map { _.toInt }
    val l = br.readLine().toInt
    val q = br.readLine().toInt

    val days = Array.ofDim[Int](n, n)
    for (i <- 0 until n - 1) {
      var result = 0
      for (j <- i + 1 until n) {
        val move = x(j) - x(j - 1)
        if (move <= result) {
          days(i)(j) = days(i)(j - 1)
          result -= move
        } else {
          result = l
          days(i)(j) = days(i)(j - 1) + 1
          result -= move
        }
      }
    }

    for (i <- 0 until q) {
      val fromTo = br.readLine().split(" ").map(_.toInt)
      val from = fromTo.min - 1
      val to = fromTo.max - 1
      println(days(from)(to))
    }

    br.close()
  }

  def solveA() {
    val n = sc.nextInt()
    val a = sc.nextInt()
    val nums = Array.fill[Int](n)(sc.nextInt())
    var nowCount = 0
    var total = 0l
    for (i <- 1 to n) {
      nowCount = i
      calc(0, 0, 0)
    }

    def calc(count: Int, index: Int, sum: Int) {
      if (count == nowCount) {
        if (count * a == sum) {
          total += 1
        }
      } else {
        if (index < n) {
          calc(count + 1, index + 1, sum + nums(index))
          calc(count, index + 1, sum)
        }
      }
    }

    println(total)

  }
}

object Main {
  def main(args: Array[String]): Unit = {
    val app = new Main()
    app.solveA()
    //    app.solveC()

  }
}

Submission Info

Submission Time
Task C - Tak and Cards
User tochukaso
Language Scala (2.11.7)
Score 200
Code Size 1841 Byte
Status TLE
Exec Time 2105 ms
Memory 22468 KB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 200 / 200 0 / 100
Status
AC × 3
TLE × 1
AC × 12
AC × 12
TLE × 12
Set Name Test Cases
Sample example_01.txt, example_02.txt, example_03.txt, example_04.txt
Subtask1 example_01.txt, example_02.txt, example_03.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt
All example_01.txt, example_02.txt, example_03.txt, example_04.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt
Case Name Status Exec Time Memory
example_01.txt AC 718 ms 22468 KB
example_02.txt AC 703 ms 21956 KB
example_03.txt AC 706 ms 21700 KB
example_04.txt TLE 2105 ms 21964 KB
subtask1_01.txt AC 738 ms 21948 KB
subtask1_02.txt AC 738 ms 21940 KB
subtask1_03.txt AC 718 ms 21932 KB
subtask1_04.txt AC 738 ms 21792 KB
subtask1_05.txt AC 718 ms 22080 KB
subtask1_06.txt AC 742 ms 21576 KB
subtask1_07.txt AC 762 ms 22080 KB
subtask1_08.txt AC 737 ms 21832 KB
subtask1_09.txt AC 726 ms 21936 KB
subtask2_01.txt TLE 2105 ms 21828 KB
subtask2_02.txt TLE 2105 ms 21828 KB
subtask2_03.txt TLE 2101 ms 21924 KB
subtask2_04.txt TLE 2104 ms 22080 KB
subtask2_05.txt TLE 2104 ms 21828 KB
subtask2_06.txt TLE 2105 ms 21912 KB
subtask2_07.txt TLE 2105 ms 21716 KB
subtask2_08.txt TLE 2105 ms 21956 KB
subtask2_09.txt TLE 2105 ms 21788 KB
subtask2_10.txt TLE 2105 ms 22092 KB
subtask2_11.txt TLE 2105 ms 21692 KB