結果
| 問題 | No.1594 Three Classes | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-07-09 21:40:18 | 
| 言語 | Java (openjdk 23) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 142 ms / 2,000 ms | 
| コード長 | 783 bytes | 
| コンパイル時間 | 2,189 ms | 
| コンパイル使用メモリ | 77,252 KB | 
| 実行使用メモリ | 41,292 KB | 
| 最終ジャッジ日時 | 2024-11-16 07:37:35 | 
| 合計ジャッジ時間 | 5,611 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 18 | 
ソースコード
import java.util.Scanner;
public class Main {
	static int N = 0;
	static int[] E = null;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = Integer.parseInt(sc.next());
		E = new int[N];
		for ( int i = 0 ; i < N ; i++ ) {
			E[i] = Integer.parseInt(sc.next());
		}
		sc.close();
		if ( rec(0, 0, 0, 0) ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
	
	static boolean rec(int pos, int pa, int pb, int pc) {
		if ( pos == N ) {
			if ( pa == pb && pb == pc ) {
				return true;
			} else {
				return false;
			}
		}
		
		if ( rec(pos + 1, pa + E[pos], pb, pc) ) return true;
		if ( rec(pos + 1, pa, pb + E[pos], pc) ) return true;
		if ( rec(pos + 1, pa, pb, pc + E[pos]) ) return true;
		
		return false;
	}
}
            
            
            
        