結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー kotatsugamekotatsugame
提出日時 2019-12-19 02:16:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 188 ms / 2,500 ms
コード長 794 bytes
コンパイル時間 666 ms
コンパイル使用メモリ 72,632 KB
実行使用メモリ 39,156 KB
最終ジャッジ日時 2023-09-21 04:45:27
合計ジャッジ時間 4,290 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 4 ms
6,232 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 3 ms
6,192 KB
testcase_11 AC 132 ms
34,104 KB
testcase_12 AC 135 ms
34,336 KB
testcase_13 AC 120 ms
31,996 KB
testcase_14 AC 19 ms
14,896 KB
testcase_15 AC 89 ms
30,232 KB
testcase_16 AC 163 ms
38,208 KB
testcase_17 AC 23 ms
14,964 KB
testcase_18 AC 179 ms
38,160 KB
testcase_19 AC 111 ms
34,064 KB
testcase_20 AC 26 ms
17,084 KB
testcase_21 AC 10 ms
12,712 KB
testcase_22 AC 18 ms
17,036 KB
testcase_23 AC 4 ms
6,296 KB
testcase_24 AC 99 ms
30,024 KB
testcase_25 AC 188 ms
39,156 KB
testcase_26 AC 187 ms
38,944 KB
testcase_27 AC 175 ms
38,876 KB
testcase_28 AC 188 ms
38,880 KB
testcase_29 AC 156 ms
38,856 KB
testcase_30 AC 105 ms
38,928 KB
testcase_31 AC 81 ms
38,860 KB
testcase_32 AC 182 ms
38,892 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(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