Submission #3237094
Source Code Expand
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top * * @author mikit */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; Scanner in = new Scanner(inputStream); PrintWriter out = new PrintWriter(outputStream); CTravelingPlan solver = new CTravelingPlan(); solver.solve(1, in, out); out.close(); } static class CTravelingPlan { public void solve(int testNumber, Scanner in, PrintWriter out) { int n = in.nextInt(); int[] x = new int[n + 2]; for (int i = 1; i <= n; i++) { x[i] = in.nextInt(); } long sum = 0; for (int i = 0; i <= n; i++) { sum += Math.abs(x[i] - x[i + 1]); } for (int i = 1; i <= n; i++) { out.println(sum - Math.abs(x[i] - x[i - 1]) - Math.abs(x[i + 1] - x[i]) + Math.abs(x[i + 1] - x[i - 1])); } } } }
Submission Info
Submission Time | |
---|---|
Task | C - Traveling Plan |
User | mikit |
Language | Java8 (OpenJDK 1.8.0) |
Score | 300 |
Code Size | 1259 Byte |
Status | AC |
Exec Time | 507 ms |
Memory | 53520 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 | 507 ms | 53052 KB |
02.txt | AC | 485 ms | 50980 KB |
03.txt | AC | 92 ms | 20560 KB |
04.txt | AC | 471 ms | 51204 KB |
05.txt | AC | 468 ms | 48992 KB |
06.txt | AC | 454 ms | 46976 KB |
07.txt | AC | 487 ms | 53520 KB |
08.txt | AC | 495 ms | 48064 KB |
09.txt | AC | 454 ms | 49844 KB |
10.txt | AC | 470 ms | 48744 KB |
11.txt | AC | 494 ms | 46152 KB |
12.txt | AC | 445 ms | 46252 KB |
sample-01.txt | AC | 94 ms | 23764 KB |
sample-02.txt | AC | 92 ms | 22996 KB |
sample-03.txt | AC | 93 ms | 19284 KB |