結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー rhincodon66rhincodon66
提出日時 2019-12-13 23:08:34
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 446 ms / 2,500 ms
コード長 1,195 bytes
コンパイル時間 1,874 ms
コンパイル使用メモリ 175,356 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-10 04:44:22
合計ジャッジ時間 8,582 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 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 2 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 219 ms
4,380 KB
testcase_12 AC 263 ms
4,376 KB
testcase_13 AC 203 ms
4,376 KB
testcase_14 AC 29 ms
4,380 KB
testcase_15 AC 174 ms
4,376 KB
testcase_16 AC 352 ms
4,400 KB
testcase_17 AC 44 ms
4,380 KB
testcase_18 AC 410 ms
4,400 KB
testcase_19 AC 201 ms
4,376 KB
testcase_20 AC 40 ms
4,376 KB
testcase_21 AC 13 ms
4,380 KB
testcase_22 AC 25 ms
4,380 KB
testcase_23 AC 3 ms
4,380 KB
testcase_24 AC 204 ms
4,376 KB
testcase_25 AC 359 ms
4,388 KB
testcase_26 AC 394 ms
4,380 KB
testcase_27 AC 393 ms
4,428 KB
testcase_28 AC 446 ms
4,380 KB
testcase_29 AC 290 ms
4,500 KB
testcase_30 AC 197 ms
4,440 KB
testcase_31 AC 171 ms
4,428 KB
testcase_32 AC 365 ms
4,380 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 main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n + 1), b(n + 1), d(n);
	rep(i,n + 1) cin >> a.at(i);
	rep(i,n + 1) cin >> b.at(i);
	rep(i,n) cin >> d.at(i);
	sort(d.begin(),d.end());
	int ok = 0, ng = n + 1;
	while(ng - ok > 1){
		int mid = (ok + ng) / 2;
		vector<vector<bool>> dp(n + 1,vector<bool>(n + 1));
		dp[0][0] = true;
		rep(i,n){
			rep(j,n){
				if(i + j >= mid) continue;
				if(!dp[i][j]) continue;
				if(a.at(i) + b.at(j + 1) >= d.at(mid - i - (j + 1))) dp[i][j + 1] = true;
				if(a.at(i + 1) + b.at(j) >= d.at(mid - (i + 1) - j)) dp[i + 1][j] = true;
			}
		}
		bool flg = false;
		rep(i,mid + 1) if(dp[i][mid - i]) flg = true;
		if(flg) ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
}
0