0 分求助

P2367 语文成绩

tohmasu @ 2023-11-23 20:35:38

fun main(args: Array<String>): Unit {
    val (n, p) = readln().split(' ').map(String::toInt)
    val a: IntArray = readln().split(' ').map(String::toInt).toIntArray()
    val b: IntArray = IntArray(n + 1)
    for (i in 0 until p) {
        val (x, y, z) = readln().split(' ').map(String::toInt)
        b[x - 1] += z
        b[y] -= z
    }
    var c: Int = 0
    var res: Int = 1000000
    for (i in 0 until n) {
        c += b[i]
        res = kotlin.math.min(res, a[i] + c)
    }
    println(res)
    return Unit
}

0 分提交

我们 Kotlin 怎么你了?


|