結果

問題 No.1470 Mex Sum
ユーザー ripityripity
提出日時 2021-12-13 20:47:38
言語 Java21
(openjdk 21)
結果
AC  
実行時間 688 ms / 2,000 ms
コード長 547 bytes
コンパイル時間 3,164 ms
コンパイル使用メモリ 71,812 KB
実行使用メモリ 66,484 KB
最終ジャッジ日時 2023-09-30 02:06:27
合計ジャッジ時間 32,936 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,576 KB
testcase_01 AC 124 ms
55,744 KB
testcase_02 AC 282 ms
60,560 KB
testcase_03 AC 303 ms
60,160 KB
testcase_04 AC 275 ms
60,144 KB
testcase_05 AC 296 ms
60,436 KB
testcase_06 AC 299 ms
60,148 KB
testcase_07 AC 285 ms
60,304 KB
testcase_08 AC 296 ms
60,372 KB
testcase_09 AC 278 ms
60,148 KB
testcase_10 AC 300 ms
59,964 KB
testcase_11 AC 289 ms
60,368 KB
testcase_12 AC 649 ms
63,748 KB
testcase_13 AC 623 ms
63,656 KB
testcase_14 AC 643 ms
63,764 KB
testcase_15 AC 632 ms
64,740 KB
testcase_16 AC 663 ms
65,528 KB
testcase_17 AC 652 ms
63,824 KB
testcase_18 AC 631 ms
64,768 KB
testcase_19 AC 659 ms
63,672 KB
testcase_20 AC 647 ms
62,912 KB
testcase_21 AC 672 ms
63,476 KB
testcase_22 AC 679 ms
64,544 KB
testcase_23 AC 664 ms
64,356 KB
testcase_24 AC 627 ms
62,964 KB
testcase_25 AC 658 ms
64,816 KB
testcase_26 AC 635 ms
64,628 KB
testcase_27 AC 637 ms
64,852 KB
testcase_28 AC 674 ms
63,084 KB
testcase_29 AC 644 ms
64,560 KB
testcase_30 AC 645 ms
64,680 KB
testcase_31 AC 663 ms
64,532 KB
testcase_32 AC 645 ms
64,556 KB
testcase_33 AC 688 ms
63,796 KB
testcase_34 AC 650 ms
64,664 KB
testcase_35 AC 634 ms
65,012 KB
testcase_36 AC 649 ms
63,856 KB
testcase_37 AC 627 ms
65,032 KB
testcase_38 AC 610 ms
65,052 KB
testcase_39 AC 632 ms
64,944 KB
testcase_40 AC 612 ms
65,112 KB
testcase_41 AC 609 ms
64,736 KB
testcase_42 AC 597 ms
66,416 KB
testcase_43 AC 614 ms
64,884 KB
testcase_44 AC 611 ms
65,480 KB
testcase_45 AC 616 ms
64,388 KB
testcase_46 AC 630 ms
64,684 KB
testcase_47 AC 640 ms
64,732 KB
testcase_48 AC 628 ms
65,880 KB
testcase_49 AC 653 ms
66,484 KB
testcase_50 AC 673 ms
65,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long ans = 0;
        long[] cnt = new long[3];
        for( int i = 0; i < N; i++ ) {
            int a = sc.nextInt()-1;
            cnt[Math.min(2,a)]++;
        }
        
        ans += cnt[0]*(cnt[0]-1)+cnt[0]*cnt[2]*2;
        ans += cnt[0]*cnt[1]*3;
        ans += (cnt[1]+cnt[2])*(cnt[1]+cnt[2]-1)/2;
        System.out.println(ans);
        
    }
    
}
0