結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー rhincodon66rhincodon66
提出日時 2019-12-12 01:19:01
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,351 bytes
コンパイル時間 1,928 ms
コンパイル使用メモリ 177,912 KB
実行使用メモリ 73,864 KB
最終ジャッジ日時 2023-09-06 13:41:14
合計ジャッジ時間 9,354 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 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 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 894 ms
53,156 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 70 ms
37,416 KB
testcase_16 AC 121 ms
67,192 KB
testcase_17 AC 32 ms
11,156 KB
testcase_18 AC 128 ms
70,688 KB
testcase_19 AC 96 ms
53,416 KB
testcase_20 AC 20 ms
13,352 KB
testcase_21 AC 6 ms
7,224 KB
testcase_22 AC 12 ms
12,096 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 149 ms
39,952 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 152 ms
73,708 KB
testcase_28 AC 148 ms
73,804 KB
testcase_29 AC 154 ms
73,788 KB
testcase_30 AC 89 ms
73,600 KB
testcase_31 AC 60 ms
73,524 KB
testcase_32 AC 181 ms
73,740 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<pii>> dp;

int dfs(int A, int B, int k){
	if(dp[A][B].first != -1 && dp[A][B].first >= k) return dp[A][B].second;
	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);
	}
	dp[A][B].first = k;
	dp[A][B].second = ans;
	return 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] = mp(-1,-1);
	}
	rep(i,n) cin >> d.at(i);
	sort(d.rbegin(),d.rend());
	int ans = dfs(0,0,0);
	cout << ans << endl;
}
0