結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー kotatsugamekotatsugame
提出日時 2019-12-19 02:04:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 704 bytes
コンパイル時間 865 ms
コンパイル使用メモリ 74,716 KB
実行使用メモリ 11,120 KB
最終ジャッジ日時 2023-09-21 04:43:11
合計ジャッジ時間 3,196 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
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 AC 10 ms
7,448 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 RE -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 2 ms
4,380 KB
testcase_24 RE -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 RE -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:9:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    9 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int N;
int A[3333],B[3333];
vector<int>D;
bool 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++)
	{
		int d;cin>>d;D.push_back(d);
	}
	sort(D.begin(),D.end());
	reverse(D.begin(),D.end());
	int ans=0;
	dp[0][0]=true;
	for(int d:D)
	{
		for(int i=0;i<=ans;i++)
		{
			int j=ans-i;
			if(!dp[i][j])continue;
			if(i<N)
			{
				int nxt=A[i+1]+B[j];
				if(nxt>=d)
				{
					dp[i+1][j]=true;
					ans=i+j+1;
				}
			}
			if(j<N)
			{
				int nxt=A[i]+B[j+1];
				if(nxt>=d)
				{
					dp[i][j+1]=true;
					ans=i+j+1;
				}
			}
		}
	}
	cout<<ans<<endl;
}
0