結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー FF256grhyFF256grhy
提出日時 2019-12-12 00:52:39
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 227 ms / 2,500 ms
コード長 2,664 bytes
コンパイル時間 1,693 ms
コンパイル使用メモリ 173,912 KB
実行使用メモリ 38,548 KB
最終ジャッジ日時 2023-09-06 13:39:16
合計ジャッジ時間 5,392 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 157 ms
28,248 KB
testcase_12 AC 162 ms
28,336 KB
testcase_13 AC 144 ms
25,420 KB
testcase_14 AC 21 ms
6,492 KB
testcase_15 AC 79 ms
20,232 KB
testcase_16 AC 142 ms
34,916 KB
testcase_17 AC 26 ms
7,376 KB
testcase_18 AC 206 ms
36,896 KB
testcase_19 AC 100 ms
28,116 KB
testcase_20 AC 22 ms
8,432 KB
testcase_21 AC 6 ms
5,584 KB
testcase_22 AC 11 ms
7,640 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 102 ms
21,460 KB
testcase_25 AC 225 ms
38,464 KB
testcase_26 AC 227 ms
38,352 KB
testcase_27 AC 158 ms
38,364 KB
testcase_28 AC 219 ms
38,404 KB
testcase_29 AC 147 ms
38,532 KB
testcase_30 AC 76 ms
38,548 KB
testcase_31 AC 50 ms
38,396 KB
testcase_32 AC 189 ms
38,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
auto fl = [](auto a, auto b) { assert(b != 0); return a / b - (a % b != 0 && ((a >= 0) != (b >= 0)) ? 1 : 0); };
auto ce = [](auto a, auto b) { assert(b != 0); return a / b + (a % b != 0 && ((a >= 0) == (b >= 0)) ? 1 : 0); };
auto mo = [](auto a, auto b) { assert(b != 0); a %= b; if(a < 0) { a += abs(b); } return a; };
LL gcd(LL a, LL b) { return (b == 0 ? a : gcd(b, a % b)); }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)

// ---- ----

#define T0(T) T
#define T1(T) vector<T0(T)>
#define T2(T) vector<T1(T)>
#define V0(v, T,    ...) v
#define V1(v, T, n, ...) T1(T)(n, V0(v, T, __VA_ARGS__))
#define V2(v, T, n, ...) T2(T)(n, V1(v, T, __VA_ARGS__))

#define LB(v, x) (lower_bound(ALL(v), x) - v.begin())
#define UB(v, x) (upper_bound(ALL(v), x) - v.begin())

int main() {
	int n;
	cin >> n;
	vector<int> a(n + 1), b(n + 1), d(n + 1);
	inc(i, n + 1) { cin >> a[i]; }
	inc(i, n + 1) { cin >> b[i]; }
	inc(i, n + 0) { cin >> d[i]; }
	d[n] = -1e6;
	sort(ALL(d));
	
	auto dp = V2(0, int, n + 1, n + 1);
	dp[0][0] = n + 1;
	int ans = 0;
	incII(i, 0, n) {
	incII(j, 0, n) {
		if_not(inII(i + j, 1, n)) { continue; }
		
		int x = (i == 0 ? 0 : dp[i - 1][j]);
		int y = (j == 0 ? 0 : dp[i][j - 1]);
		int z = max(x, y);
		if(z == 0) { continue; }
		
		int p = UB(d, a[i] + b[j]) - 1;
		if(p >= z) { p = z - 1; }
		dp[i][j] = p;
		if(p > 0) { setmax(ans, i + j); }
	}
	}
	
	cout << ans << endl;
	
	return 0;
}
0