結果

問題 No.586 ダブルブッキング
ユーザー Grenache
提出日時 2017-11-03 22:24:16
言語 Java
(openjdk 23)
結果
AC  
実行時間 139 ms / 2,000 ms
コード長 825 bytes
コンパイル時間 3,231 ms
コンパイル使用メモリ 75,260 KB
実行使用メモリ 41,720 KB
最終ジャッジ日時 2024-11-22 15:52:14
合計ジャッジ時間 4,760 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;


public class Main_yukicoder586 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int p1 = sc.nextInt();
		int p2 = sc.nextInt();
		int n = sc.nextInt();

		int[] r = new int[n];
		int[] rr = new int[999];
		for (int i = 0; i < n; i++) {
			r[i] = sc.nextInt();

			rr[r[i] - 1]++;
		}

		long ans = 0;
		for (int i = 0; i < 999; i++) {
			if (rr[i] > 1) {
				ans += (long)(p1 + p2) * (rr[i] - 1);
			}
		}

		pr.println(ans);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0