結果

問題 No.1823 Tricolor Dango
ユーザー ks2m
提出日時 2022-01-28 22:11:27
言語 Java
(openjdk 23)
結果
AC  
実行時間 965 ms / 2,000 ms
コード長 651 bytes
コンパイル時間 4,971 ms
コンパイル使用メモリ 74,476 KB
実行使用メモリ 57,820 KB
最終ジャッジ日時 2024-12-30 07:19:59
合計ジャッジ時間 23,821 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int t= sc.nextInt();
		PrintWriter pw = new PrintWriter(System.out);
		for (int z = 0; z < t; z++) {
			int n = sc.nextInt();
			int[] a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = sc.nextInt();
			}

			Arrays.sort(a);
			long sum = 0;
			for (int i = 0; i < n; i++) {
				sum += a[i];
			}
			if (sum % 3 == 0 && a[n - 1] <= sum / 3) {
				pw.println("Yes");
			} else {
				pw.println("No");
			}
		}
		pw.flush();
		sc.close();
	}
}
0