結果

問題 No.561 東京と京都
コンテスト
ユーザー fjafjafja
提出日時 2017-09-01 17:39:47
言語 Java
(openjdk 26.0.2.1 + ACL)
コンパイル:
javac -J-Duser.language=en -encoding UTF8 -cp /opt/aclib/ac_library.jar _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true -cp .:/opt/aclib/ac_library.jar _class_
結果
TLE  
実行時間 -
コード長 649 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,488 ms
コンパイル使用メモリ 86,040 KB
実行使用メモリ 46,008 KB
最終ジャッジ日時 2026-09-19 19:04:48
合計ジャッジ時間 9,730 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 7 TLE * 1 -- * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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