結果

問題 No.561 東京と京都
ユーザー fjafjafja
提出日時 2017-09-01 17:39:47
言語 Java
(openjdk 23)
結果
TLE  
実行時間 -
コード長 649 bytes
コンパイル時間 6,428 ms
コンパイル使用メモリ 77,172 KB
実行使用メモリ 47,468 KB
最終ジャッジ日時 2024-11-06 17:24:39
合計ジャッジ時間 10,531 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 7 TLE * 1 -- * 9
権限があれば一括ダウンロードができます

ソースコード

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