Submission #3604337
Source Code Expand
fun c92(args: Array<String>) { val numList = listOf(0).plus(args[1].split(" ").map { it.toInt() }).plus(0) val cost = (0..numList.size - 2).map { Math.abs(numList[it + 1] - numList[it]) }.sum() val ans = (0..numList.size - 3) .map { val before = Math.abs(numList[it + 2] - numList[it + 1]) + Math.abs(numList[it + 1] - numList[it]) val after = Math.abs(numList[it + 2] - numList[it]) cost - (before - after) } .joinToString("\n") println(ans) } fun main(args: Array<String>) { c92(readLineList()) } fun readLineList(): Array<String> { val lineList = mutableListOf<String>() while (true) { val line = readLine() if (line.isNullOrBlank()) { break } else { lineList.add(line!!) } } return lineList.toTypedArray() }
Submission Info
Submission Time | |
---|---|
Task | C - Traveling Plan |
User | choruru |
Language | Kotlin (1.0.0) |
Score | 300 |
Code Size | 921 Byte |
Status | AC |
Exec Time | 642 ms |
Memory | 59544 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample-01.txt, sample-02.txt, sample-03.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, sample-01.txt, sample-02.txt, sample-03.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 642 ms | 59076 KB |
02.txt | AC | 638 ms | 59012 KB |
03.txt | AC | 235 ms | 37908 KB |
04.txt | AC | 638 ms | 57312 KB |
05.txt | AC | 639 ms | 55764 KB |
06.txt | AC | 639 ms | 55372 KB |
07.txt | AC | 642 ms | 57508 KB |
08.txt | AC | 641 ms | 59544 KB |
09.txt | AC | 619 ms | 56132 KB |
10.txt | AC | 620 ms | 56088 KB |
11.txt | AC | 610 ms | 52824 KB |
12.txt | AC | 620 ms | 54200 KB |
sample-01.txt | AC | 237 ms | 34244 KB |
sample-02.txt | AC | 235 ms | 36264 KB |
sample-03.txt | AC | 235 ms | 36292 KB |