Submission #1068114


Source Code Expand

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	private static Scanner sc;

	public static void main(String[] args) {
		Main instance = new Main();
		sc = instance.new Scanner();
		instance.solve();
	}

	private void solve() {
		try {
			int N = sc.nextInt();
			long A = sc.nextInt();
			long B = sc.nextInt();

			long[] ary = new long[N];
			for (int i = 0; i<N;i++) {
				ary[i] = sc.nextLong();
			}

			long ret =0;
			for (int i = 0; i < N-1; i++) {
				ret += Math.min((ary[i+1]-ary[i])*A, B);
			}

			System.out.println(ret);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private class Scanner {
		String[] s;
		int i;
		BufferedReader br;
		String regex = " ";

		public Scanner() {
			s = new String[0];
			i = 0;
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		@Override
		protected void finalize() throws Throwable {
			try {
				super.finalize();
			} finally {
				destruction();
			}
		}

		private void destruction() throws IOException {
			if (br != null)
				br.close();
		}

		public String next() throws IOException {
			if (i < s.length)
				return s[i++];
			String st = br.readLine();
			while (st == "")
				st = br.readLine();
			s = st.split(regex, 0);
			i = 0;
			return s[i++];
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public Long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public Double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}
	}
}

Submission Info

Submission Time
Task D - Walk and Teleport
User macchi09
Language Java8 (OpenJDK 1.8.0)
Score 500
Code Size 1738 Byte
Status AC
Exec Time 261 ms
Memory 34996 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 12
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 101 ms 8148 KB
sample_02.txt AC 100 ms 8272 KB
sample_03.txt AC 99 ms 8148 KB
subtask_1_balancedmax_01.txt AC 261 ms 34792 KB
subtask_1_balancedmax_02.txt AC 247 ms 34772 KB
subtask_1_max_01.txt AC 256 ms 34948 KB
subtask_1_max_02.txt AC 240 ms 34788 KB
subtask_1_min_01.txt AC 100 ms 8148 KB
subtask_1_onlya_01.txt AC 200 ms 20624 KB
subtask_1_onlyamax_01.txt AC 247 ms 34996 KB
subtask_1_onlyb_01.txt AC 161 ms 15180 KB
subtask_1_onlybmax_01.txt AC 247 ms 34992 KB
subtask_1_rand_01.txt AC 220 ms 22928 KB
subtask_1_rand_02.txt AC 257 ms 32332 KB
subtask_1_rand_03.txt AC 176 ms 17232 KB