結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー kotatsugamekotatsugame
提出日時 2019-12-19 02:10:35
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 173 ms / 2,500 ms
コード長 820 bytes
コンパイル時間 709 ms
コンパイル使用メモリ 72,852 KB
実行使用メモリ 39,104 KB
最終ジャッジ日時 2023-09-21 04:45:05
合計ジャッジ時間 3,978 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 4 ms
6,228 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 3 ms
6,336 KB
testcase_11 AC 119 ms
34,348 KB
testcase_12 AC 122 ms
34,140 KB
testcase_13 AC 108 ms
32,032 KB
testcase_14 AC 17 ms
14,840 KB
testcase_15 AC 77 ms
29,928 KB
testcase_16 AC 140 ms
38,236 KB
testcase_17 AC 21 ms
14,980 KB
testcase_18 AC 161 ms
38,172 KB
testcase_19 AC 91 ms
34,100 KB
testcase_20 AC 22 ms
17,080 KB
testcase_21 AC 8 ms
12,732 KB
testcase_22 AC 14 ms
17,016 KB
testcase_23 AC 3 ms
6,272 KB
testcase_24 AC 90 ms
29,996 KB
testcase_25 AC 170 ms
38,916 KB
testcase_26 AC 170 ms
39,104 KB
testcase_27 AC 153 ms
38,836 KB
testcase_28 AC 173 ms
38,856 KB
testcase_29 AC 129 ms
38,856 KB
testcase_30 AC 69 ms
38,884 KB
testcase_31 AC 41 ms
38,916 KB
testcase_32 AC 162 ms
39,104 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    8 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int N;
int A[3333],B[3333],D[3333];
int dp[3030][3030];
main()
{
	cin>>N;
	for(int i=0;i<=N;i++)cin>>A[i];
	for(int i=0;i<=N;i++)cin>>B[i];
	for(int i=0;i<N;i++)cin>>D[i];
	sort(D,D+N);
	for(int i=0;i<=N;i++)for(int j=0;j<=N;j++)dp[i][j]=-1;
	dp[0][0]=N;
	for(int i=0;i<=N;i++)for(int j=0;j<=N;j++)
	{
		if(dp[i][j]<0)continue;
		if(i<N)
		{
			int nxt=A[i+1]+B[j];
			int id=upper_bound(D,D+dp[i][j],nxt)-D;
			id--;
			if(id>=0)
			{
				dp[i+1][j]=max(dp[i+1][j],id);
			}
		}
		if(j<N)
		{
			int nxt=A[i]+B[j+1];
			int id=upper_bound(D,D+dp[i][j],nxt)-D;
			id--;
			if(id>=0)
			{
				dp[i][j+1]=max(dp[i][j+1],id);
			}
		}
	}
	int ans=0;
	for(int i=0;i<=N;i++)for(int j=0;j<=N;j++)if(dp[i][j]>=0)ans=max(ans,i+j);
	cout<<ans<<endl;
}
0