結果

問題 No.545 ママの大事な二人の子供
ユーザー fjafjafjafjafjafja
提出日時 2017-07-17 18:09:01
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 665 bytes
コンパイル時間 3,546 ms
コンパイル使用メモリ 74,980 KB
実行使用メモリ 47,264 KB
最終ジャッジ日時 2024-04-16 23:54:54
合計ジャッジ時間 13,149 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
45,496 KB
testcase_01 AC 135 ms
41,292 KB
testcase_02 AC 138 ms
41,324 KB
testcase_03 AC 137 ms
41,228 KB
testcase_04 AC 138 ms
41,584 KB
testcase_05 AC 137 ms
41,308 KB
testcase_06 AC 123 ms
40,008 KB
testcase_07 AC 139 ms
41,432 KB
testcase_08 AC 139 ms
41,296 KB
testcase_09 AC 136 ms
41,444 KB
testcase_10 AC 138 ms
41,396 KB
testcase_11 AC 141 ms
41,520 KB
testcase_12 AC 146 ms
41,644 KB
testcase_13 AC 158 ms
41,620 KB
testcase_14 AC 170 ms
41,312 KB
testcase_15 AC 140 ms
41,668 KB
testcase_16 AC 185 ms
41,440 KB
testcase_17 AC 302 ms
41,524 KB
testcase_18 TLE -
testcase_19 TLE -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class N545
{

	public static void main(String[] args)
	{
		int min=100000;
		int abs=0;
		int total=0;
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] a=new int[n];
		int[] b=new int[n];
		for(int i=0;i<n;i++)//1-n
		{
			a[i]=sc.nextInt();
			b[i]=sc.nextInt();
		
		}
		int l=0;
		
while(l<Math.pow(2,n))
{
		int k=1;
		int atotal=0;
		int btotal=0;
		int count=0;

		while(k<Math.pow(2,n))
		{
			if((k&l)!=0)
			{
				atotal+=a[count];
			}
			else
			{
				btotal+=b[count];
			}
			k=k*2;
			count++;
		}
		k=1;
		abs=Math.abs(atotal-btotal);
		min=(abs<min)?abs:min;
	l++;
}
System.out.println(min);
	}

}
0