結果

問題 No.1827 最長部分スーパーリッチ門松列列
ユーザー yudedakoyudedako
提出日時 2022-01-30 17:59:51
言語 Scala(Beta)
(3.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 699 bytes
コンパイル時間 14,009 ms
コンパイル使用メモリ 254,808 KB
実行使用メモリ 131,352 KB
最終ジャッジ日時 2023-09-02 01:43:28
合計ジャッジ時間 55,184 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 942 ms
62,240 KB
testcase_01 AC 946 ms
62,272 KB
testcase_02 AC 952 ms
62,516 KB
testcase_03 AC 1,367 ms
66,216 KB
testcase_04 AC 1,568 ms
64,500 KB
testcase_05 AC 1,550 ms
64,636 KB
testcase_06 AC 1,547 ms
64,256 KB
testcase_07 AC 1,457 ms
125,992 KB
testcase_08 AC 1,453 ms
123,856 KB
testcase_09 AC 1,456 ms
123,940 KB
testcase_10 AC 1,451 ms
123,776 KB
testcase_11 AC 1,460 ms
126,256 KB
testcase_12 AC 1,424 ms
123,756 KB
testcase_13 AC 1,435 ms
123,624 KB
testcase_14 AC 1,447 ms
123,720 KB
testcase_15 AC 1,452 ms
123,648 KB
testcase_16 AC 1,439 ms
123,800 KB
testcase_17 TLE -
testcase_18 TLE -
testcase_19 AC 1,651 ms
130,920 KB
testcase_20 AC 1,644 ms
130,428 KB
testcase_21 AC 1,648 ms
130,504 KB
testcase_22 AC 1,671 ms
131,352 KB
testcase_23 AC 1,667 ms
130,432 KB
testcase_24 AC 1,647 ms
130,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import scala.collection.mutable
import scala.io.StdIn.*
import scala.math.*
@main def main =
  val testCase = readLine().toInt
  for _ <- 0 until testCase do
    val n = readLine().toInt
    val permutation = readLine().split(' ').map(_.toInt)
    val isUpper = Array.fill(n){true}
    var count = 1
    var result = 0
    for i <- permutation.indices.sortBy(permutation) do
      if i > 0 then
        if isUpper(i - 1) == isUpper(i) then
          count += 1
        else
          count -= 1
      if i + 1 < n then
        if isUpper(i) == isUpper(i + 1) then
          count += 1
        else
          count -= 1
      isUpper(i) = false
      result = max(result, count)
    println(result)
0