結果

問題 No.3010 水色コーダーさん
ユーザー Torikun9971
提出日時 2025-02-01 18:22:50
言語 Kotlin
(2.1.0)
結果
AC  
実行時間 756 ms / 2,000 ms
コード長 3,526 bytes
コンパイル時間 18,752 ms
コンパイル使用メモリ 490,360 KB
実行使用メモリ 104,960 KB
最終ジャッジ日時 2025-02-01 18:23:29
合計ジャッジ時間 35,213 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.InputStream
import java.io.PrintStream

fun main() {
    val reader = FastReader()
    val writer = FastWriter()

    val (N, M) = reader.readInts()
    val S = mutableListOf<String>()
    val R = mutableListOf<Int>()
    var count = 0

    repeat(N) {
        S.add(reader.read())
        R.add(reader.readInt())
    }

    for (i in 0 until N) {
        if (R[i] >= 1200) {
            if (S[i].take(4).any { it == 'x' }) {
                count++
            }
        }
    }

    writer.append(count).println()
}

class FastReader(private val stream: InputStream = System.`in`) {
    private val buffer = ByteArray(1024 * 16)
    private var size = 0
    private var pos = 0
    private var isEnded = false

    private fun checkAndReplenishment() {
        if (isEnded || size > pos) return

        size = stream.read(buffer, 0, buffer.size)
        pos = 0
        if (size < 0) isEnded = true
    }

    fun readByte(): Byte {
        checkAndReplenishment()
        return buffer[pos++]
    }

    fun read(): String {
        val bytes = mutableListOf<Byte>()

        while (true) {
            val byte = readByte()

            if (byte == SPACE || byte == LINE_FEED) break
            bytes.add(byte)
        }

        return bytes.toByteArray().toString(Charsets.UTF_8)
    }

    fun readLine(): String {
        val bytes = mutableListOf<Byte>()

        while (true) {
            val byte = readByte()

            if (byte == LINE_FEED) break
            bytes.add(byte)
        }

        return bytes.toByteArray().toString(Charsets.UTF_8)
    }

    fun skip(i: Int = 1): FastReader {
        repeat(i) {
            while (readByte() != LINE_FEED) {}
        }

        return this
    }

    fun readChar(): Char = read()[0]
    fun readInt(): Int = read().toInt()
    fun readLong(): Long = read().toLong()
    fun readFloat(): Float = read().toFloat()
    fun readDouble(): Double = read().toDouble()
    fun readBoolean(): Boolean = read().toBoolean()
    fun readList(): List<String> = readLine().split(" ")
    fun readChars(): List<Char> = readLine().split(" ").map { it[0] }
    fun readInts(): List<Int> = readLine().split(" ").map { it.toInt() }
    fun readInts(adjust: Int): List<Int> = readLine().split(" ").map { it.toInt() + adjust }
    fun readLongs(): List<Long> = readLine().split(" ").map { it.toLong() }
    fun readLongs(adjust: Long): List<Long> = readLine().split(" ").map { it.toLong() + adjust }
    fun readFloats(): List<Float> = readLine().split(" ").map { it.toFloat() }
    fun readDoubles(): List<Double> = readLine().split(" ").map { it.toDouble() }
    fun readBooleans(): List<Boolean> = readLine().split(" ").map { it.toBoolean() }

    companion object {
        private const val SPACE = ' '.code.toByte()
        private const val LINE_FEED = '\n'.code.toByte()
    }
}

class FastWriter(private val stream: PrintStream = System.out, private val capacity: Int = 1024 * 1024 * 8) {
    private val writeText = StringBuilder()

    fun append(any: Any? = ""): FastWriter {
        writeText.append(any)
        checkCapacity()
        return this
    }

    fun appendLine(any: Any? = ""): FastWriter {
        writeText.appendLine(any)
        checkCapacity()
        return this
    }

    fun print() {
        stream.print(writeText)
        writeText.clear()
    }

    fun println() {
        stream.println(writeText)
        writeText.clear()
    }

    private fun checkCapacity() {
        if (writeText.length > capacity) print()
    }
}
0