結果

問題 No.1594 Three Classes
ユーザー ripityripity
提出日時 2021-12-13 22:51:49
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 888 bytes
コンパイル時間 3,743 ms
コンパイル使用メモリ 71,924 KB
実行使用メモリ 103,516 KB
最終ジャッジ日時 2023-09-30 04:31:28
合計ジャッジ時間 26,543 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,662 ms
90,520 KB
testcase_01 AC 133 ms
55,752 KB
testcase_02 AC 130 ms
55,424 KB
testcase_03 AC 275 ms
66,340 KB
testcase_04 AC 1,829 ms
92,036 KB
testcase_05 AC 1,857 ms
92,032 KB
testcase_06 AC 319 ms
67,908 KB
testcase_07 AC 366 ms
67,944 KB
testcase_08 TLE -
testcase_09 AC 1,711 ms
91,620 KB
testcase_10 TLE -
testcase_11 AC 1,702 ms
92,168 KB
testcase_12 AC 1,672 ms
90,532 KB
testcase_13 AC 146 ms
56,040 KB
testcase_14 AC 762 ms
87,068 KB
testcase_15 AC 1,184 ms
92,072 KB
testcase_16 AC 543 ms
76,656 KB
testcase_17 AC 1,325 ms
92,300 KB
testcase_18 AC 140 ms
55,796 KB
testcase_19 AC 225 ms
63,056 KB
testcase_20 AC 265 ms
64,976 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++ ) {
            String state = String.format("%-13s",Integer.toString(i,3)).replace(" ","0");
            char[] c = state.toCharArray();
            int[] sum = new int[3];
            for( int j = 0; j < N; j++ ) {
                int index = c[j]-'0';
                sum[index] += E[j];
            }
            if( sum[0] == sum[1] && sum[1] == sum[2] ) {
                System.out.println("Yes");
                return;
            }
        }
        
        System.out.println("No");
        
    }
    
}
0