結果

問題 No.582 キャンディー・ボックス3
ユーザー GrenacheGrenache
提出日時 2017-10-27 23:55:58
言語 Java21
(openjdk 21)
結果
AC  
実行時間 135 ms / 2,000 ms
コード長 1,170 bytes
コンパイル時間 3,467 ms
コンパイル使用メモリ 74,652 KB
実行使用メモリ 40,116 KB
最終ジャッジ日時 2023-08-14 13:21:27
合計ジャッジ時間 6,919 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
39,340 KB
testcase_01 AC 117 ms
39,216 KB
testcase_02 AC 116 ms
39,700 KB
testcase_03 AC 118 ms
39,280 KB
testcase_04 AC 118 ms
39,744 KB
testcase_05 AC 119 ms
39,840 KB
testcase_06 AC 122 ms
40,096 KB
testcase_07 AC 117 ms
40,048 KB
testcase_08 AC 117 ms
39,364 KB
testcase_09 AC 118 ms
39,636 KB
testcase_10 AC 118 ms
39,836 KB
testcase_11 AC 119 ms
39,720 KB
testcase_12 AC 118 ms
39,256 KB
testcase_13 AC 127 ms
39,464 KB
testcase_14 AC 127 ms
39,336 KB
testcase_15 AC 131 ms
39,784 KB
testcase_16 AC 134 ms
39,996 KB
testcase_17 AC 132 ms
39,516 KB
testcase_18 AC 132 ms
40,116 KB
testcase_19 AC 135 ms
39,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;


public class Main_yukicoder582 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();

		int[] c = new int[n];
		int cnt = 0;
		int sum = 0;
		int cnt1 = 0;
		int cnt2 = 0;
		for (int i = 0; i < n; i++) {
			c[i] = sc.nextInt();

			if (c[i] > 0) {
				cnt++;
			}
			sum += c[i];
			if (c[i] == 1) {
				cnt1++;
			}
			if (c[i] == 2) {
				cnt2++;
			}
		}

		if (cnt == 1) {
			if (sum == 1) {
				pr.println('A');
			} else {
				pr.println('B');
			}
		} else {
			if (cnt1 == cnt) {
				if (cnt % 2 == 0) {
					pr.println('B');
				} else {
					pr.println('A');
				}
			} else if (cnt2 == 1 && cnt2 + cnt1 == cnt) {
				if (cnt1 % 2 == 0) {
					pr.println('B');
				} else {
					pr.println('A');
				}
			} else {
				pr.println('B');
			}
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0