結果
問題 | No.561 東京と京都 |
ユーザー | hhgfhn1 |
提出日時 | 2018-10-29 21:06:29 |
言語 | Java21 (openjdk 21) |
結果 |
TLE
|
実行時間 | - |
コード長 | 714 bytes |
コンパイル時間 | 2,218 ms |
コンパイル使用メモリ | 77,128 KB |
実行使用メモリ | 47,384 KB |
最終ジャッジ日時 | 2024-04-29 23:14:09 |
合計ジャッジ時間 | 7,464 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 130 ms
46,320 KB |
testcase_01 | AC | 135 ms
41,156 KB |
testcase_02 | AC | 120 ms
40,008 KB |
testcase_03 | AC | 129 ms
41,228 KB |
testcase_04 | AC | 134 ms
41,448 KB |
testcase_05 | AC | 135 ms
41,128 KB |
testcase_06 | AC | 135 ms
41,200 KB |
testcase_07 | AC | 132 ms
41,104 KB |
testcase_08 | AC | 136 ms
41,008 KB |
testcase_09 | AC | 134 ms
41,000 KB |
testcase_10 | AC | 127 ms
40,296 KB |
testcase_11 | TLE | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
ソースコード
import java.util.Scanner; public class Main { @SuppressWarnings("resource") public static void main(String args[]) { Scanner scanner = new Scanner(System.in); int n=scanner.nextInt(); int d=scanner.nextInt(); t=new int[n]; k=new int[n]; for(int i=0;i<n;i++) { t[i]=scanner.nextInt(); k[i]=scanner.nextInt(); } dfs(0,0,true,d,n); System.out.println(max); } static int t[]; static int k[]; static int max=0; private static void dfs(int i, int c, boolean is_t, int d, int n) { if(i==n) { max=Math.max(max, c); return; } if(is_t) { dfs(i+1,c+t[i],true,d,n); dfs(i+1,c+k[i]-d,false,d,n); }else { dfs(i+1,c+t[i]-d,true,d,n); dfs(i+1,c+k[i],false,d,n); } } }