結果
問題 | No.949 飲酒プログラミングコンテスト |
ユーザー | 37zigen |
提出日時 | 2019-12-12 21:03:22 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,019 bytes |
コンパイル時間 | 3,016 ms |
コンパイル使用メモリ | 74,512 KB |
実行使用メモリ | 69,696 KB |
最終ジャッジ日時 | 2023-09-07 21:42:06 |
合計ジャッジ時間 | 14,322 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 118 ms
55,520 KB |
testcase_01 | AC | 120 ms
55,812 KB |
testcase_02 | AC | 118 ms
55,520 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 198 ms
56,500 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
ソースコード
import java.util.Arrays; import java.util.Scanner; class Main { public static void main(String[] args) { new Main().run(); } void run() { Scanner sc = new Scanner(System.in); int N=sc.nextInt(); long[] A=new long[N+1]; long[] B=new long[N+1]; long[] D=new long[N+1]; for(int i=0;i<=N;++i){ A[i]=sc.nextLong(); } for(int i=0;i<=N;++i){ B[i]=sc.nextLong(); } for(int i=0;i<N;++i){ D[i+1]=sc.nextLong(); } boolean[][] dp=new boolean[N+1][N+1]; for(int i=0;i<dp.length;++i) for(int j=0;j<dp[i].length;++j) dp[i][j]=false; dp[0][0]=true; for(int i=1;i<=N;++i){ for(int a=0;a<=N;++a){ int b=i-a; if(b<0||b>N)continue; if(D[i]<=A[a]+B[b]){ if(a>0) dp[i][a]|=dp[i-1][a-1]; if(b>0) dp[i][a]|=dp[i-1][a]; } } } int ans=0; for(int i=0;i<=N;++i){ for(int j=0;j<=N;++j){ if(dp[i][j]) ans=Math.max(ans,i); } } System.out.println(ans); } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }