結果

問題 No.1594 Three Classes
コンテスト
ユーザー ripity
提出日時 2021-12-13 22:51:49
言語 Java
(openjdk 26.0.2.1 + ACL)
コンパイル:
javac -J-Duser.language=en -encoding UTF8 -cp /opt/aclib/ac_library.jar _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true -cp .:/opt/aclib/ac_library.jar _class_
結果
AC  
実行時間 733 ms / 2,000 ms
+ 173µs
コード長 888 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,087 ms
コンパイル使用メモリ 85,180 KB
実行使用メモリ 64,084 KB
最終ジャッジ日時 2026-08-23 14:08:41
合計ジャッジ時間 11,535 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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