Submission #7033359


Source Code Expand

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

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun <K, V> Map<K, V>.toMutableMap(): MutableMap<K, V> = HashMap(this)

fun<T> List<T>.toBuckets(bucketKeys: List<T>): Map<T, Int> {
    val buckets = bucketKeys.associate { t -> Pair(t, 0) }.toMutableMap()
    this.forEach { t ->
        buckets[t] = buckets[t]!! + 1
    }
    return buckets
}

fun main(args: Array<String>) {
    val n = readInt()
    val answers = read().toList()
    val collectRates = answers.toBuckets("1234".toList()).values.toList().sorted()
    val max = collectRates.last()
    val min = collectRates.first()
    println("$max $min")
    pw.flush()
}

/****** Declared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}

Submission Info

Submission Time
Task A - センター採点
User pokotsun
Language Kotlin (1.0.0)
Score 100
Code Size 3254 Byte
Status AC
Exec Time 241 ms
Memory 38312 KB

Compile Error

Main.kt:21:9: warning: variable 'n' is never used
    val n = readInt()
        ^

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 30
Set Name Test Cases
All 00_sample1.txt, 00_sample2.txt, 01_rnd_00.txt, 01_rnd_01.txt, 01_rnd_02.txt, 01_rnd_03.txt, 01_rnd_04.txt, 01_rnd_05.txt, 01_rnd_06.txt, 01_rnd_07.txt, 01_rnd_08.txt, 01_rnd_09.txt, 01_rnd_10.txt, 01_rnd_11.txt, 01_rnd_12.txt, 01_rnd_13.txt, 01_rnd_14.txt, 01_rnd_15.txt, 01_rnd_16.txt, 01_rnd_17.txt, 01_rnd_18.txt, 01_rnd_19.txt, 02_all_1.txt, 02_all_2.txt, 02_all_3.txt, 02_all_4.txt, 03_mini_1.txt, 03_mini_2.txt, 03_mini_3.txt, 03_mini_4.txt
Case Name Status Exec Time Memory
00_sample1.txt AC 241 ms 34496 KB
00_sample2.txt AC 232 ms 38184 KB
01_rnd_00.txt AC 233 ms 34372 KB
01_rnd_01.txt AC 233 ms 36412 KB
01_rnd_02.txt AC 232 ms 38176 KB
01_rnd_03.txt AC 234 ms 36392 KB
01_rnd_04.txt AC 234 ms 36292 KB
01_rnd_05.txt AC 232 ms 34288 KB
01_rnd_06.txt AC 235 ms 36272 KB
01_rnd_07.txt AC 237 ms 36512 KB
01_rnd_08.txt AC 233 ms 38088 KB
01_rnd_09.txt AC 233 ms 36356 KB
01_rnd_10.txt AC 233 ms 36292 KB
01_rnd_11.txt AC 232 ms 34304 KB
01_rnd_12.txt AC 233 ms 34400 KB
01_rnd_13.txt AC 234 ms 34344 KB
01_rnd_14.txt AC 232 ms 36260 KB
01_rnd_15.txt AC 232 ms 34336 KB
01_rnd_16.txt AC 232 ms 34284 KB
01_rnd_17.txt AC 234 ms 36268 KB
01_rnd_18.txt AC 232 ms 36256 KB
01_rnd_19.txt AC 232 ms 36384 KB
02_all_1.txt AC 232 ms 36264 KB
02_all_2.txt AC 233 ms 36312 KB
02_all_3.txt AC 232 ms 36256 KB
02_all_4.txt AC 234 ms 38312 KB
03_mini_1.txt AC 233 ms 32532 KB
03_mini_2.txt AC 232 ms 36296 KB
03_mini_3.txt AC 232 ms 36420 KB
03_mini_4.txt AC 232 ms 36388 KB