結果

問題 No.1594 Three Classes
ユーザー ripityripity
提出日時 2021-12-13 22:54:54
言語 Java21
(openjdk 21)
結果
AC  
実行時間 184 ms / 2,000 ms
コード長 800 bytes
コンパイル時間 2,077 ms
コンパイル使用メモリ 74,748 KB
実行使用メモリ 57,032 KB
最終ジャッジ日時 2024-04-28 00:45:26
合計ジャッジ時間 6,037 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 164 ms
56,312 KB
testcase_01 AC 117 ms
53,156 KB
testcase_02 AC 130 ms
53,792 KB
testcase_03 AC 144 ms
53,916 KB
testcase_04 AC 184 ms
56,228 KB
testcase_05 AC 167 ms
56,260 KB
testcase_06 AC 144 ms
54,096 KB
testcase_07 AC 145 ms
53,792 KB
testcase_08 AC 181 ms
57,032 KB
testcase_09 AC 183 ms
56,228 KB
testcase_10 AC 169 ms
56,564 KB
testcase_11 AC 169 ms
56,184 KB
testcase_12 AC 178 ms
56,388 KB
testcase_13 AC 134 ms
53,688 KB
testcase_14 AC 159 ms
56,728 KB
testcase_15 AC 132 ms
55,624 KB
testcase_16 AC 132 ms
53,432 KB
testcase_17 AC 145 ms
53,708 KB
testcase_18 AC 132 ms
54,084 KB
testcase_19 AC 131 ms
53,820 KB
testcase_20 AC 130 ms
53,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] E = new int[N];
        for( int i = 0; i < N; i++ ) {
            E[i] = sc.nextInt();
        }
        
        int lim = (int)Math.pow(3,N);
        for( int i = 0; i < lim; i++ ) {
            int state = i;
            int[] sum = new int[3];
            for( int j = 0; j < N; j++ ) {
                int d = state%3;
                state /= 3;
                sum[d] += E[j];
            }
            if( sum[0] == sum[1] && sum[1] == sum[2] ) {
                System.out.println("Yes");
                return;
            }
        }
        
        System.out.println("No");
        
    }
    
}
0