結果

問題 No.2210 equence Squence Seuence
ユーザー 👑 箱
提出日時 2023-02-10 21:45:11
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 678 ms / 2,000 ms
コード長 1,310 bytes
コンパイル時間 19,258 ms
コンパイル使用メモリ 422,016 KB
実行使用メモリ 66,140 KB
最終ジャッジ日時 2023-09-21 22:53:45
合計ジャッジ時間 32,788 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 324 ms
56,972 KB
testcase_01 AC 316 ms
58,824 KB
testcase_02 AC 320 ms
57,324 KB
testcase_03 AC 519 ms
58,248 KB
testcase_04 AC 537 ms
58,348 KB
testcase_05 AC 558 ms
60,516 KB
testcase_06 AC 549 ms
60,160 KB
testcase_07 AC 622 ms
62,500 KB
testcase_08 AC 327 ms
56,924 KB
testcase_09 AC 326 ms
56,952 KB
testcase_10 AC 324 ms
59,140 KB
testcase_11 AC 319 ms
57,104 KB
testcase_12 AC 324 ms
58,820 KB
testcase_13 AC 633 ms
66,036 KB
testcase_14 AC 678 ms
64,188 KB
testcase_15 AC 640 ms
66,080 KB
testcase_16 AC 639 ms
64,716 KB
testcase_17 AC 645 ms
66,140 KB
testcase_18 AC 325 ms
56,964 KB
testcase_19 AC 326 ms
58,880 KB
testcase_20 AC 327 ms
56,844 KB
testcase_21 AC 321 ms
56,908 KB
testcase_22 AC 336 ms
57,240 KB
testcase_23 AC 618 ms
65,692 KB
testcase_24 AC 607 ms
64,004 KB
testcase_25 AC 614 ms
64,268 KB
testcase_26 AC 644 ms
66,032 KB
testcase_27 AC 538 ms
58,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter
import java.util.*
import kotlin.math.*

fun PrintWriter.solve() {
    val n = nextInt()
    val k = nextInt()
    val a = Array(n) { nextInt() }
    var l = 1
    var r = n
    var ans = 0
    var carry = 1
    for (i in 0 until n - 1) {
        if (a[i] < a[i + 1]) {
            r -= carry
            carry = 1
            if (k > r) break
        } else if (a[i] > a[i + 1]) {

            l += carry
            carry = 1
            if (l > k) break
        } else {
            carry++
        }
        ans++
    }
    val b = a.toMutableList()
    b.removeAt(ans)
    println(b.joinToString(" "))
}

fun main() {
    Thread(null, {
        val writer = PrintWriter(System.out, false)
        writer.solve()
        writer.flush()
    }, "solve", abs(1L.shl(26)))
        .apply { setUncaughtExceptionHandler { _, e -> e.printStackTrace(); kotlin.system.exitProcess(1) } }
        .apply { start() }.join()
}

// region Scanner
private var st = StringTokenizer("")
private val br = System.`in`.bufferedReader()

fun next(): String {
    while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())
    return st.nextToken()
}

fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextLine() = br.readLine()
fun nextDouble() = next().toDouble()
// endregion
0