結果

問題 No.1738 What's in the box?
ユーザー 👑 箱星箱星
提出日時 2021-11-12 22:24:52
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 300 ms / 2,000 ms
コード長 1,015 bytes
コンパイル時間 10,356 ms
コンパイル使用メモリ 440,676 KB
実行使用メモリ 62,500 KB
最終ジャッジ日時 2024-05-04 09:32:31
合計ジャッジ時間 33,204 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 274 ms
62,428 KB
testcase_01 AC 273 ms
62,344 KB
testcase_02 AC 274 ms
62,376 KB
testcase_03 AC 297 ms
62,416 KB
testcase_04 AC 284 ms
62,480 KB
testcase_05 AC 288 ms
62,360 KB
testcase_06 AC 296 ms
62,480 KB
testcase_07 AC 292 ms
62,492 KB
testcase_08 AC 287 ms
62,488 KB
testcase_09 AC 285 ms
62,420 KB
testcase_10 AC 289 ms
62,320 KB
testcase_11 AC 300 ms
62,416 KB
testcase_12 AC 298 ms
62,500 KB
testcase_13 AC 286 ms
62,140 KB
testcase_14 AC 281 ms
62,300 KB
testcase_15 AC 279 ms
62,468 KB
testcase_16 AC 280 ms
62,416 KB
testcase_17 AC 300 ms
62,384 KB
testcase_18 AC 290 ms
62,404 KB
testcase_19 AC 290 ms
62,312 KB
testcase_20 AC 293 ms
62,452 KB
testcase_21 AC 294 ms
62,396 KB
testcase_22 AC 282 ms
62,424 KB
testcase_23 AC 270 ms
62,468 KB
testcase_24 AC 283 ms
62,324 KB
testcase_25 AC 286 ms
62,172 KB
testcase_26 AC 281 ms
62,460 KB
testcase_27 AC 278 ms
62,344 KB
testcase_28 AC 279 ms
62,452 KB
testcase_29 AC 273 ms
62,384 KB
testcase_30 AC 288 ms
62,324 KB
testcase_31 AC 276 ms
62,164 KB
testcase_32 AC 282 ms
62,032 KB
testcase_33 AC 288 ms
62,396 KB
testcase_34 AC 286 ms
62,456 KB
testcase_35 AC 288 ms
62,440 KB
testcase_36 AC 284 ms
62,344 KB
testcase_37 AC 286 ms
62,460 KB
testcase_38 AC 288 ms
62,328 KB
testcase_39 AC 281 ms
62,232 KB
testcase_40 AC 291 ms
62,428 KB
testcase_41 AC 293 ms
62,400 KB
testcase_42 AC 295 ms
62,488 KB
testcase_43 AC 278 ms
62,164 KB
testcase_44 AC 283 ms
62,436 KB
testcase_45 AC 288 ms
62,480 KB
testcase_46 AC 292 ms
62,496 KB
testcase_47 AC 281 ms
62,404 KB
testcase_48 AC 286 ms
62,304 KB
testcase_49 AC 296 ms
62,492 KB
testcase_50 AC 281 ms
62,324 KB
testcase_51 AC 291 ms
62,340 KB
testcase_52 AC 284 ms
62,488 KB
testcase_53 AC 269 ms
62,340 KB
testcase_54 AC 279 ms
62,332 KB
testcase_55 AC 276 ms
62,304 KB
testcase_56 AC 281 ms
62,248 KB
testcase_57 AC 275 ms
62,348 KB
testcase_58 AC 287 ms
62,208 KB
testcase_59 AC 288 ms
62,424 KB
testcase_60 AC 281 ms
62,480 KB
testcase_61 AC 296 ms
62,200 KB
testcase_62 AC 287 ms
62,388 KB
testcase_63 AC 282 ms
62,480 KB
testcase_64 AC 283 ms
62,212 KB
testcase_65 AC 279 ms
62,444 KB
testcase_66 AC 279 ms
62,460 KB
testcase_67 AC 272 ms
62,392 KB
testcase_68 AC 278 ms
62,416 KB
testcase_69 AC 280 ms
62,292 KB
testcase_70 AC 275 ms
62,196 KB
testcase_71 AC 281 ms
62,468 KB
testcase_72 AC 275 ms
62,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

fun PrintWriter.solve() {
    val n = nextInt()
    val m = nextLong()
    val w = Array(n) { nextLong() }
    val s = w.sum()
    if (s == 0L) {
        println(Array(n) { 0 }.joinToString(" "))
    } else {
        println(w.map { it * m / s }.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