結果

問題 No.586 ダブルブッキング
ユーザー matsuyoshi30matsuyoshi30
提出日時 2018-05-30 23:35:51
言語 Java21
(openjdk 21)
結果
AC  
実行時間 134 ms / 2,000 ms
コード長 721 bytes
コンパイル時間 2,016 ms
コンパイル使用メモリ 72,336 KB
実行使用メモリ 56,704 KB
最終ジャッジ日時 2023-09-12 20:52:38
合計ジャッジ時間 3,987 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
56,028 KB
testcase_01 AC 125 ms
56,704 KB
testcase_02 AC 124 ms
55,728 KB
testcase_03 AC 132 ms
56,100 KB
testcase_04 AC 123 ms
55,992 KB
testcase_05 AC 134 ms
55,920 KB
testcase_06 AC 123 ms
55,976 KB
testcase_07 AC 124 ms
56,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main {
    public static void main(String[] args) {
        // input
        Scanner in = new Scanner(System.in);
        int p1 = in.nextInt();
        int p2 = in.nextInt();
        int n = in.nextInt();
        int[] r = new int[n];
        for(int i=0; i<n; i++)
            r[i] = in.nextInt();

        // sort
        Arrays.sort(r);

        int count = 0;
        int i = 0;
        while(i<n) {
            int temp = r[i];
            int j;
            for(j=i+1; j<n; j++) {
                if(temp == r[j])
                    count++;
                else
                    break;
            }
            i = j;
        }

        System.out.println((p1+p2) * count);
    }
}
0