AtCoder Beginner Contest 064

Submission #1340933

Source codeソースコード

import java.io.*
import java.util.InputMismatchException
import java.io.IOException
import kotlin.system.measureTimeMillis
var out = PrintWriter(System.out)
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/

var line = intArrayOf(1, 400, 800, 1200, 1600, 2000, 2400, 2800, 5050)
fun solve() {
    var N = ni()
    var A = na(N)
    A.sort()

    var color:MutableSet<Int> = mutableSetOf()
    var non = 0
    for(a in A) {
        if(3200 <= a) {
            non++
            continue
        }

        for(j in 0..7) {
            if(a in line[j] until line[j + 1]) color.add(j)
        }
    }

    var max = color.size + non
    var min = Math.max(color.size, 1)
    out.println("$min $max")
}









//---------------------------------------------------------------------------------------------------
fun main(args: Array<String>) {
    var time = measureTimeMillis {
        solve()
        out.flush()
    }
    //println("$time ms")
}
//---------------------------------------------------------------------------------------------------
private var inbuf = ByteArray(1024)
private var lenbuf = 0
var ptrbuf = 0

var `is` = System.`in`

fun readByte(): Byte {
    if (lenbuf === -1) throw InputMismatchException()
    if (ptrbuf >= lenbuf) {
        ptrbuf = 0
        try {
            lenbuf = `is`.read(inbuf)
        } catch (e: IOException) {
            throw InputMismatchException()
        }

        if (lenbuf <= 0) return -1
    }
    return inbuf[ptrbuf++]
}


private fun isSpaceChar(c: Byte): Boolean {
    return !(c >= 33 && c <= 126)
}

private fun skip(): Byte {
    var b: Byte
    while (true) {
        b = readByte()
        if(b < 0 && isSpaceChar(b)) break
    }
    return b
}

private fun ns(): String {
    var b = skip()
    val sb = StringBuilder()
    while (!isSpaceChar(b)) {
        sb.appendCodePoint(b.toInt())
        b = readByte()
    }
    return sb.toString()
}

fun na(n: Int) = IntArray(n, {ni()})

fun ni(): Int {
    var num = 0
    var b: Byte
    var minus = false
    while (true) {
        b = readByte()
        if(b < 0) break
        if(b >= '0'.toByte() && b <= '9'.toByte() || b == '-'.toByte()) break

        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
    }

    while (true) {
        if (b >= '0'.toByte() && b <= '9'.toByte()) {
            num = num * 10 + (b - '0'.toByte())
        } else {
            return if (minus) -num else num
        }
        b = readByte()
    }
}

Submission

Task問題 C - Colorful Leaderboard
User nameユーザ名 はまやんはまやん
Created time投稿日時
Language言語 Kotlin (1.0.0)
Status状態 AC
Score得点 300
Source lengthソースコード長 3105 Byte
File nameファイル名
Exec time実行時間 183 ms
Memory usageメモリ使用量 31692 KB

Compiler messageコンパイルメッセージ

Main.kt:50:9: warning: variable 'time' is never used
var time = measureTimeMillis {
^
Main.kt:115:13: warning: the value 'readByte()' assigned to 'var b: kotlin.Byte defined in ni' is never used
b = readByte()
^

Test case

Set

Set name Score得点 / Max score Cases
Sample - s1.txt,s2.txt,s3.txt
All 300 / 300 in1.txt,in2.txt,in3.txt,in4.txt,in5.txt,s1.txt,s2.txt,s3.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
in1.txt AC 180 ms 31692 KB
in2.txt AC 179 ms 27712 KB
in3.txt AC 181 ms 31556 KB
in4.txt AC 181 ms 31444 KB
in5.txt AC 183 ms 27712 KB
s1.txt AC 181 ms 29772 KB
s2.txt AC 179 ms 31552 KB
s3.txt AC 180 ms 31432 KB