Submission #856216


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())

    val first = nums.count(_ == a)
    if (n == 1) println(first)
    else {
      var second = 0
      for (i <- 0 until n - 1; j <- i + 1 until n) {
        if (nums(i) + nums(j) == a * 2) second += 1
      }
      var total = first + second
      for (i <- 2 until n) {

      }

      println(total)
    }

  }
}

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

  }
}

Submission Info

Submission Time
Task E - Tak and Hotels
User tochukaso
Language Scala (2.11.7)
Score 200
Code Size 1713 Byte
Status MLE
Exec Time 1723 ms
Memory 275832 KB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 200 / 200 0 / 500
Status
AC × 1
AC × 14
AC × 14
MLE × 13
Set Name Test Cases
Sample example_01.txt
Subtask1 example_01.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, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt
All example_01.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, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.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, subtask2_12.txt, subtask2_13.txt
Case Name Status Exec Time Memory
example_01.txt AC 711 ms 22712 KB
subtask1_01.txt AC 715 ms 22472 KB
subtask1_02.txt AC 793 ms 22344 KB
subtask1_03.txt AC 903 ms 27904 KB
subtask1_04.txt AC 891 ms 28748 KB
subtask1_05.txt AC 891 ms 28708 KB
subtask1_06.txt AC 873 ms 24688 KB
subtask1_07.txt AC 835 ms 24760 KB
subtask1_08.txt AC 903 ms 29052 KB
subtask1_09.txt AC 907 ms 29096 KB
subtask1_10.txt AC 904 ms 28872 KB
subtask1_11.txt AC 919 ms 28776 KB
subtask1_12.txt AC 894 ms 28928 KB
subtask1_13.txt AC 875 ms 27684 KB
subtask2_01.txt MLE 1635 ms 275712 KB
subtask2_02.txt MLE 1655 ms 275244 KB
subtask2_03.txt MLE 1659 ms 275720 KB
subtask2_04.txt MLE 1635 ms 275588 KB
subtask2_05.txt MLE 1591 ms 275480 KB
subtask2_06.txt MLE 1623 ms 275832 KB
subtask2_07.txt MLE 1699 ms 275380 KB
subtask2_08.txt MLE 1651 ms 274836 KB
subtask2_09.txt MLE 1659 ms 275532 KB
subtask2_10.txt MLE 1659 ms 275540 KB
subtask2_11.txt MLE 1627 ms 275240 KB
subtask2_12.txt MLE 1679 ms 275504 KB
subtask2_13.txt MLE 1723 ms 275804 KB