Submission #4027194
Source Code Expand
import java.io.{InputStream, OutputStream, PrintStream} import java.util.Scanner import scala.annotation.tailrec object Main { def main(args: Array[String]): Unit = { val solver = new Solver(System.in, System.out) solver.solve() } class Solver(in: InputStream, out: OutputStream) { lazy val input = new Scanner(in) lazy val output = new PrintStream(out) def solve(): Unit = { val Array(n, k) = input.nextLine().split(" ").map(_.toInt) val xs = input.nextLine().split(" ").map(_.toInt) output.println(0.to(n - k).map { i => val l = xs(i) val r = xs(i + k - 1) // output.println(l, r) (Math.abs(l) + Math.abs(r - l)).min(Math.abs(r) + Math.abs(r - l)) }.min) } @tailrec final def gcd(m: Int, n: Int): Int = { val (x, y) = if (m > n) (m, n) else (n, m) if (y != 0) gcd(y, x % y) else x } } }
Submission Info
Submission Time | |
---|---|
Task | C - Candles |
User | lambdasawa |
Language | Scala (2.11.7) |
Score | 300 |
Code Size | 959 Byte |
Status | AC |
Exec Time | 707 ms |
Memory | 46832 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 333 ms | 25404 KB |
0_01.txt | AC | 333 ms | 25524 KB |
0_02.txt | AC | 333 ms | 25416 KB |
0_03.txt | AC | 338 ms | 23500 KB |
1_00.txt | AC | 622 ms | 45368 KB |
1_01.txt | AC | 685 ms | 45584 KB |
1_02.txt | AC | 584 ms | 41840 KB |
1_03.txt | AC | 675 ms | 45832 KB |
1_04.txt | AC | 593 ms | 44544 KB |
1_05.txt | AC | 658 ms | 45668 KB |
1_06.txt | AC | 683 ms | 43640 KB |
1_07.txt | AC | 707 ms | 46832 KB |