結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー 37zigen
提出日時 2019-12-12 21:03:22
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 1,019 bytes
コンパイル時間 2,566 ms
コンパイル使用メモリ 77,856 KB
実行使用メモリ 65,520 KB
最終ジャッジ日時 2024-06-25 15:18:05
合計ジャッジ時間 13,351 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 1 WA * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

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));
	}

}
0