結果

問題 No.973 余興
ユーザー yakamotoyakamoto
提出日時 2020-01-18 16:37:46
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 2,023 bytes
コンパイル時間 19,533 ms
コンパイル使用メモリ 426,372 KB
実行使用メモリ 145,616 KB
最終ジャッジ日時 2023-09-09 23:56:53
合計ジャッジ時間 62,392 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 898 ms
144,328 KB
testcase_01 AC 905 ms
144,272 KB
testcase_02 AC 911 ms
145,004 KB
testcase_03 WA -
testcase_04 AC 902 ms
144,396 KB
testcase_05 WA -
testcase_06 AC 899 ms
144,640 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 900 ms
144,228 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 518 ms
82,060 KB
testcase_14 AC 518 ms
81,920 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 354 ms
55,992 KB
testcase_18 WA -
testcase_19 AC 356 ms
56,216 KB
testcase_20 WA -
testcase_21 AC 360 ms
56,152 KB
testcase_22 AC 360 ms
56,268 KB
testcase_23 AC 361 ms
55,920 KB
testcase_24 WA -
testcase_25 AC 351 ms
55,352 KB
testcase_26 AC 360 ms
55,980 KB
testcase_27 WA -
testcase_28 AC 364 ms
55,960 KB
testcase_29 AC 359 ms
56,088 KB
testcase_30 AC 965 ms
145,496 KB
testcase_31 AC 957 ms
145,320 KB
testcase_32 AC 976 ms
145,616 KB
testcase_33 AC 951 ms
145,360 KB
testcase_34 AC 931 ms
144,844 KB
testcase_35 AC 953 ms
144,912 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 967 ms
144,912 KB
testcase_40 AC 309 ms
52,912 KB
testcase_41 AC 297 ms
53,032 KB
testcase_42 AC 297 ms
52,904 KB
testcase_43 WA -
testcase_44 AC 306 ms
52,956 KB
testcase_45 WA -
testcase_46 WA -
testcase_47 AC 925 ms
144,936 KB
testcase_48 WA -
testcase_49 WA -
testcase_50 AC 900 ms
144,800 KB
testcase_51 AC 913 ms
144,744 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 AC 1,020 ms
145,016 KB
testcase_55 AC 1,083 ms
144,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import kotlin.math.min

val MOD = 1_000_000_007

fun main() {
  val (N, X) = readInts()
  val A = readInts()

  val dpL = Array(N){IntArray(N - it + 1)}
  val dpR = Array(N){IntArray(it + 2)}
  val mxR = run {
    val res = IntArray(N)
    var sum = 0L
    var r = N - 1
    for (l in N - 1 downTo 0) {
      sum += A[l]
      while (r > l && sum > X) {
        sum -= A[r]
        r--
      }
      res[l] = r - l + 1
    }
    res
  }
  debug(mxR)
  val mxL = run {
    val res = IntArray(N)
    var sum = 0L
    var l = 0
    for (r in 0 until N) {
      sum += A[r]
      while (l < r && sum > X) {
        sum -= A[l]
        l++
      }
      res[r] = r - l + 1
    }
    res
  }
  debug(mxL)

  for (d in 1 until N) {
    for (l in 0 until N - d) {
      val r = l + d
      val llen = min(d, mxR[l])
      val lwin = dpL[l][d] - dpL[l][d-llen] < llen
      val rlen = min(d, mxL[r])
      val rwin = dpR[r][d] - dpR[r][d-rlen] < rlen
      val win = if (lwin or rwin) 1 else 0
//      debug{"$l $r $win"}
      dpL[l][d+1] = dpL[l][d] + win
      dpR[r][d+1] = dpR[r][d] + win
    }
  }

  debugDim(dpL)
  debugDim(dpR)

  if (dpL[0][N] - dpL[0][N-1] == 1) println("A")
  else println("B")
}












































private val isDebug = try {
  // なんか本番でエラーでる
  System.getenv("MY_DEBUG") != null
} catch (t: Throwable) {
  false
}

private fun readLn() = readLine()!!
private fun readStrings() = readLn().split(" ")
private fun readInts() = readStrings().map { it.toInt() }.toIntArray()
private fun readLongs() = readStrings().map { it.toLong() }.toLongArray()
private inline fun debug(msg: () -> String) {
  if (isDebug) System.err.println(msg())
}
private fun debug(a: LongArray) {
  debug{a.joinToString(" ")}
}
private fun debug(a: IntArray) {
  debug{a.joinToString(" ")}
}
private fun debug(a: BooleanArray) {
  debug{a.map{if(it) 1 else 0}.joinToString("")}
}
private fun debugDim(A: Array<IntArray>) {
  if (isDebug) {
    for (a in A) {
      debug(a)
    }
  }
}
0