Submission #2210399


Source Code Expand

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			long a = in.nextLong();
			long b = in.nextLong();
			long[] x = in.nextLongArray(n);
			long[] edge = new long[n-1];
			for (int i = 0; i < n - 1; i++) {
				edge[i] = (x[i+1] - x[i]) * a;
			}

			// solve
			long ans = 0;
			for (int i = 0; i < n - 1; i++) {
				ans += Math.min(b, edge[i]);
			}

			out.println(ans);

		}
	}

	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}

Submission Info

Submission Time
Task D - Walk and Teleport
User tutuz
Language Java8 (OpenJDK 1.8.0)
Score 500
Code Size 2365 Byte
Status AC
Exec Time 214 ms
Memory 39356 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 15
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, 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 71 ms 23124 KB
sample_02.txt AC 70 ms 17620 KB
sample_03.txt AC 72 ms 16468 KB
subtask_1_balancedmax_01.txt AC 178 ms 35904 KB
subtask_1_balancedmax_02.txt AC 184 ms 39356 KB
subtask_1_max_01.txt AC 179 ms 37928 KB
subtask_1_max_02.txt AC 180 ms 35884 KB
subtask_1_min_01.txt AC 72 ms 21460 KB
subtask_1_onlya_01.txt AC 166 ms 26196 KB
subtask_1_onlyamax_01.txt AC 177 ms 37244 KB
subtask_1_onlyb_01.txt AC 141 ms 28192 KB
subtask_1_onlybmax_01.txt AC 173 ms 34368 KB
subtask_1_rand_01.txt AC 165 ms 33300 KB
subtask_1_rand_02.txt AC 214 ms 34600 KB
subtask_1_rand_03.txt AC 155 ms 27292 KB