結果

問題 No.1619 Coccinellidae
ユーザー 👑 箱
提出日時 2021-07-22 22:30:08
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 479 ms / 2,000 ms
コード長 1,338 bytes
コンパイル時間 16,568 ms
コンパイル使用メモリ 422,728 KB
実行使用メモリ 59,760 KB
最終ジャッジ日時 2023-09-24 17:45:25
合計ジャッジ時間 23,653 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 290 ms
56,024 KB
testcase_01 AC 434 ms
59,620 KB
testcase_02 AC 451 ms
59,516 KB
testcase_03 AC 294 ms
56,132 KB
testcase_04 AC 479 ms
59,760 KB
testcase_05 AC 433 ms
59,452 KB
testcase_06 AC 297 ms
56,040 KB
testcase_07 AC 432 ms
59,664 KB
testcase_08 AC 424 ms
59,568 KB
testcase_09 AC 300 ms
56,108 KB
testcase_10 AC 426 ms
57,340 KB
testcase_11 AC 443 ms
59,452 KB
testcase_12 AC 296 ms
56,240 KB
testcase_13 AC 443 ms
59,456 KB
testcase_14 AC 448 ms
59,388 KB
testcase_15 AC 297 ms
56,236 KB
testcase_16 AC 292 ms
56,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

fun PrintWriter.solve() {
    val n = nextInt()
    val m = nextLong()
    var k = nextLong()
    for (i in 0 until n) {
        if (k <= n - 1 - i) {
            val a = Array(n) { 0L }
            for (j in 0 until i) {
                a[j] = n - 1L - j
            }
            val pos = ((n - 1) - k).toInt()
            a[pos] = n - 1L - i
            var b = false
            for (j in i until n) {
                if (j == pos) {
                    b = true
                    continue
                }
                a[j] = j - i.toLong() + if (b) -1 else 0
            }
            val ind = a.indexOfFirst { it == n - 1L }
            a[ind] = m - n * (n - 1L) / 2 + n - 1
            kotlin.io.println(a.joinToString("\n"))
            return
        }
        k -= n - 1 - i
    }
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve()
    writer.flush()
}

// 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