結果

問題 No.112 ややこしい鶴亀算
ユーザー youthfuldays072youthfuldays072
提出日時 2018-06-17 01:05:16
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 675 bytes
コンパイル時間 2,201 ms
コンパイル使用メモリ 74,308 KB
実行使用メモリ 57,848 KB
最終ジャッジ日時 2023-09-13 06:17:34
合計ジャッジ時間 7,435 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 152 ms
56,696 KB
testcase_01 AC 156 ms
56,988 KB
testcase_02 AC 156 ms
56,648 KB
testcase_03 AC 154 ms
57,036 KB
testcase_04 AC 154 ms
56,796 KB
testcase_05 AC 151 ms
56,620 KB
testcase_06 AC 154 ms
56,708 KB
testcase_07 AC 153 ms
56,716 KB
testcase_08 AC 154 ms
57,056 KB
testcase_09 AC 154 ms
56,832 KB
testcase_10 AC 156 ms
56,640 KB
testcase_11 AC 150 ms
56,676 KB
testcase_12 AC 154 ms
56,968 KB
testcase_13 AC 152 ms
56,860 KB
testcase_14 AC 160 ms
56,740 KB
testcase_15 WA -
testcase_16 AC 168 ms
56,592 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 161 ms
56,796 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>>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