結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー rhincodon66rhincodon66
提出日時 2019-12-12 01:14:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,274 bytes
コンパイル時間 1,705 ms
コンパイル使用メモリ 174,896 KB
実行使用メモリ 38,744 KB
最終ジャッジ日時 2023-09-06 13:40:54
合計ジャッジ時間 4,597 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 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,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 75 ms
28,044 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 49 ms
20,420 KB
testcase_16 AC 90 ms
35,388 KB
testcase_17 AC 14 ms
7,240 KB
testcase_18 AC 103 ms
36,772 KB
testcase_19 AC 64 ms
28,384 KB
testcase_20 AC 14 ms
8,276 KB
testcase_21 AC 5 ms
5,176 KB
testcase_22 AC 8 ms
7,508 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 57 ms
21,508 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 99 ms
38,580 KB
testcase_28 AC 109 ms
38,664 KB
testcase_29 AC 90 ms
38,432 KB
testcase_30 AC 56 ms
38,396 KB
testcase_31 AC 37 ms
38,368 KB
testcase_32 AC 104 ms
38,656 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}


int n;
vector<int> a,b,d;
vector<vector<int>> dp;

int dfs(int A, int B, int k){
	if(dp[A][B] != -1) return dp[A][B];
	int ans = 0;
	if(A < n){
		int t = a.at(A + 1) + b.at(B);
		int k1 = k;
		while(k1 < n && d.at(k1) > t) k1++;
		if(k1 < n) ans = dfs(A + 1, B, k1 + 1) + 1;
	}
	if(B < n){
		int t = a.at(A) + b.at(B + 1);
		int k1 = k;
		while(k1 < n && d.at(k1) > t) k1++;
		if(k1 < n) ans = max(ans,dfs(A, B + 1, k1 + 1) + 1);
	}
	return dp[A][B] = ans;
}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	a.resize(n + 1);
	b.resize(n + 1);
	d.resize(n);
	dp.resize(n + 1);
	rep(i,n + 1) cin >> a.at(i);
	rep(i,n + 1) cin >> b.at(i);
	rep(i,n + 1){
		dp.at(i).resize(n + 1);
		rep(j,n + 1) dp[i][j] = -1;
	}
	rep(i,n) cin >> d.at(i);
	sort(d.rbegin(),d.rend());
	int ans = dfs(0,0,0);
	cout << ans << endl;
}
0