結果

問題 No.112 ややこしい鶴亀算
ユーザー youthfuldays072youthfuldays072
提出日時 2018-06-17 01:14:23
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 720 bytes
コンパイル時間 2,181 ms
コンパイル使用メモリ 75,896 KB
実行使用メモリ 58,424 KB
最終ジャッジ日時 2023-09-13 06:17:44
合計ジャッジ時間 7,359 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 148 ms
56,840 KB
testcase_01 AC 148 ms
56,968 KB
testcase_02 AC 144 ms
56,824 KB
testcase_03 AC 149 ms
56,912 KB
testcase_04 AC 149 ms
57,040 KB
testcase_05 AC 151 ms
56,564 KB
testcase_06 AC 147 ms
57,032 KB
testcase_07 AC 148 ms
56,764 KB
testcase_08 AC 146 ms
56,708 KB
testcase_09 AC 150 ms
56,928 KB
testcase_10 AC 147 ms
56,900 KB
testcase_11 AC 147 ms
56,900 KB
testcase_12 AC 145 ms
56,908 KB
testcase_13 AC 148 ms
56,820 KB
testcase_14 AC 156 ms
56,704 KB
testcase_15 WA -
testcase_16 AC 166 ms
56,740 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 154 ms
56,568 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Main main=new Main();
		main.run();
	}

	void run() {

		Scanner sc=new Scanner(System.in);

		int N=sc.nextInt();

		int[] a=new int[N];

		int sum=0;
		for(int i=0;i<N;i++) {
			int buf=sc.nextInt();
			a[i]=buf;
			sum+=buf;
		}

		int legs=0;
		int kame=0;
		int sum2=0;
		for(int i=0;i<1<<N;i++) {
			legs=0;
			kame=0;
			sum2=0;
			for(int j=0;j<N;j++) {

				if(i==0 && j==0) {
					continue;
				}

				if((i>>j&1)==1) {
					legs+=4;
					sum2+=a[j]+4;
					kame++;
				}else {
					legs+=2;
					sum2+=a[j]+2;
				}

			}

			if(sum2==legs*N) {
				System.out.println((N-kame)+" "+kame);
				return;
			}

		}

	}

}

0