結果

問題 No.1110 好きな歌
ユーザー 👑 箱
提出日時 2020-07-10 21:34:54
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 1,246 ms / 5,000 ms
コード長 1,245 bytes
コンパイル時間 14,209 ms
コンパイル使用メモリ 435,084 KB
実行使用メモリ 91,700 KB
最終ジャッジ日時 2024-04-19 16:02:18
合計ジャッジ時間 56,688 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 296 ms
53,800 KB
testcase_01 AC 297 ms
53,716 KB
testcase_02 AC 297 ms
53,860 KB
testcase_03 AC 301 ms
53,604 KB
testcase_04 AC 314 ms
53,780 KB
testcase_05 AC 320 ms
54,028 KB
testcase_06 AC 310 ms
53,720 KB
testcase_07 AC 314 ms
53,688 KB
testcase_08 AC 312 ms
54,020 KB
testcase_09 AC 302 ms
53,920 KB
testcase_10 AC 306 ms
53,716 KB
testcase_11 AC 314 ms
53,848 KB
testcase_12 AC 308 ms
53,912 KB
testcase_13 AC 313 ms
53,712 KB
testcase_14 AC 334 ms
54,304 KB
testcase_15 AC 325 ms
53,840 KB
testcase_16 AC 328 ms
54,320 KB
testcase_17 AC 335 ms
54,232 KB
testcase_18 AC 307 ms
53,732 KB
testcase_19 AC 332 ms
54,324 KB
testcase_20 AC 335 ms
54,036 KB
testcase_21 AC 332 ms
54,044 KB
testcase_22 AC 335 ms
54,180 KB
testcase_23 AC 325 ms
54,076 KB
testcase_24 AC 965 ms
79,504 KB
testcase_25 AC 1,170 ms
87,740 KB
testcase_26 AC 826 ms
72,192 KB
testcase_27 AC 1,090 ms
84,384 KB
testcase_28 AC 802 ms
73,684 KB
testcase_29 AC 1,230 ms
91,136 KB
testcase_30 AC 765 ms
74,072 KB
testcase_31 AC 678 ms
66,448 KB
testcase_32 AC 1,201 ms
91,600 KB
testcase_33 AC 813 ms
76,712 KB
testcase_34 AC 901 ms
83,208 KB
testcase_35 AC 1,208 ms
90,620 KB
testcase_36 AC 518 ms
60,592 KB
testcase_37 AC 706 ms
68,856 KB
testcase_38 AC 1,114 ms
90,984 KB
testcase_39 AC 994 ms
79,476 KB
testcase_40 AC 1,091 ms
89,952 KB
testcase_41 AC 515 ms
58,624 KB
testcase_42 AC 1,034 ms
91,700 KB
testcase_43 AC 1,170 ms
90,264 KB
testcase_44 AC 1,144 ms
90,960 KB
testcase_45 AC 1,180 ms
90,224 KB
testcase_46 AC 1,124 ms
90,576 KB
testcase_47 AC 1,227 ms
90,592 KB
testcase_48 AC 1,233 ms
90,408 KB
testcase_49 AC 1,052 ms
90,596 KB
testcase_50 AC 1,128 ms
90,424 KB
testcase_51 AC 1,134 ms
90,488 KB
testcase_52 AC 1,212 ms
90,448 KB
testcase_53 AC 1,246 ms
90,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val d = sc.nextInt()
    val a = mutableListOf<Int>()
    a.add(-1)
    for (i in 0 until n) {
        a.add(sc.nextInt())
    }
    val b = a.sorted()
    for (i in 0 until n) {
        val v = a[i + 1] - d
        var l = 0
        var r = n + 1
        while (r - l > 1) {
            val mid = (l + r) / 2
            if (b[mid] <= v) {
                l = mid
            } else {
                r = mid
            }
        }
        println(l)
    }
}

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

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    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()
    fun ready() = br.ready()
}
0