結果
問題 | No.1619 Coccinellidae |
ユーザー |
|
提出日時 | 2021-07-22 22:30:08 |
言語 | Kotlin (2.1.0) |
結果 |
AC
|
実行時間 | 477 ms / 2,000 ms |
コード長 | 1,338 bytes |
コンパイル時間 | 15,131 ms |
コンパイル使用メモリ | 438,796 KB |
実行使用メモリ | 67,104 KB |
最終ジャッジ日時 | 2024-07-17 18:40:12 |
合計ジャッジ時間 | 23,316 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 16 |
ソースコード
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