Submission #1066768
Source Code Expand
import java.io.*; import java.util.*; public class Main { private static boolean debug = false; private static boolean elapsed = false; private static PrintWriter _out = new PrintWriter(System.out); private static PrintWriter _err = new PrintWriter(System.err); private int n; private long a; private long b; private long[] x; private void solve(Scanner sc) { n = sc.nextInt(); a = sc.nextLong(); b = sc.nextLong(); x = new long[n]; for (int i = 0; i < n; ++i) { x[i] = sc.nextLong(); } long cost = 0; for (int i = 0; i < n - 1; ++i) { if ((x[i + 1] - x[i]) * a > b) { cost += b; } else { cost += (x[i + 1] - x[i]) * a; } } _out.println(cost); } private long C(long n, long r) { long res = 1; for (long i = n; i > n - r; --i) { res *= i; } for (long i = r; i > 1; --i) { res /= i; } return res; } private long P(long n, long r) { long res = 1; for (long i = n; i > n - r; --i) { res *= i; } return res; } /* * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9 * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18 */ public static void main(String[] args) { long S = System.currentTimeMillis(); Scanner sc = new Scanner(System.in); new Main().solve(sc); _out.flush(); long G = System.currentTimeMillis(); if (elapsed) { _err.println((G - S) + "ms"); } _err.flush(); } }
Submission Info
Submission Time | |
---|---|
Task | D - Walk and Teleport |
User | hhelibex |
Language | Java8 (OpenJDK 1.8.0) |
Score | 500 |
Code Size | 1779 Byte |
Status | AC |
Exec Time | 551 ms |
Memory | 34584 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 500 / 500 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt, sample_03.txt |
All | subtask_1_balancedmax_01.txt, subtask_1_balancedmax_02.txt, subtask_1_max_01.txt, subtask_1_max_02.txt, subtask_1_min_01.txt, subtask_1_onlya_01.txt, subtask_1_onlyamax_01.txt, subtask_1_onlyb_01.txt, subtask_1_onlybmax_01.txt, subtask_1_rand_01.txt, subtask_1_rand_02.txt, subtask_1_rand_03.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | AC | 126 ms | 9812 KB |
sample_02.txt | AC | 125 ms | 9668 KB |
sample_03.txt | AC | 127 ms | 9804 KB |
subtask_1_balancedmax_01.txt | AC | 512 ms | 33228 KB |
subtask_1_balancedmax_02.txt | AC | 467 ms | 32696 KB |
subtask_1_max_01.txt | AC | 489 ms | 32732 KB |
subtask_1_max_02.txt | AC | 515 ms | 33244 KB |
subtask_1_min_01.txt | AC | 127 ms | 9680 KB |
subtask_1_onlya_01.txt | AC | 436 ms | 31356 KB |
subtask_1_onlyamax_01.txt | AC | 509 ms | 34068 KB |
subtask_1_onlyb_01.txt | AC | 338 ms | 29756 KB |
subtask_1_onlybmax_01.txt | AC | 551 ms | 34584 KB |
subtask_1_rand_01.txt | AC | 453 ms | 31888 KB |
subtask_1_rand_02.txt | AC | 440 ms | 32620 KB |
subtask_1_rand_03.txt | AC | 336 ms | 29600 KB |