結果

問題 No.561 東京と京都
ユーザー fjafjafjafjafjafja
提出日時 2017-09-01 17:39:47
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 649 bytes
コンパイル時間 3,039 ms
コンパイル使用メモリ 77,804 KB
実行使用メモリ 47,812 KB
最終ジャッジ日時 2024-04-24 09:54:25
合計ジャッジ時間 7,950 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
46,524 KB
testcase_01 AC 111 ms
41,172 KB
testcase_02 AC 101 ms
40,116 KB
testcase_03 AC 104 ms
40,248 KB
testcase_04 AC 108 ms
40,056 KB
testcase_05 AC 112 ms
41,164 KB
testcase_06 AC 110 ms
41,008 KB
testcase_07 AC 110 ms
41,400 KB
testcase_08 AC 113 ms
41,120 KB
testcase_09 AC 108 ms
40,628 KB
testcase_10 AC 117 ms
40,400 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

import java.util.Scanner;

public class N561
{
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int D=sc.nextInt();
		int change=0;
		int[] T=new int[N];
		int[] K=new int[N];
		int cnt=0;
		int total=0;
		int max=0;
		for(int i=0;i<N;i++)
		{
			T[i]=sc.nextInt();
			K[i]=sc.nextInt();
		}
		for(int i=0;i<(int)Math.pow(2,N);i++)
		{
			total=0;
			change=0;
			for(int j=0;j<N;j++)
			{
				if((i&(int)Math.pow(2, j))!=0)
				{
					change++;
					total-=D;
				}
				total+=(change%2==0)?T[j]:K[j];
			}
		max=(max<total)?total:max;

		}
		System.out.println(max);
	}

}
0