結果
問題 | No.949 飲酒プログラミングコンテスト |
ユーザー | 👑 jupiro |
提出日時 | 2020-02-08 15:26:53 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 685 ms / 2,500 ms |
コード長 | 1,939 bytes |
コンパイル時間 | 1,639 ms |
コンパイル使用メモリ | 119,372 KB |
実行使用メモリ | 22,112 KB |
最終ジャッジ日時 | 2023-10-26 00:50:52 |
合計ジャッジ時間 | 9,867 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 20 ms
21,856 KB |
testcase_01 | AC | 19 ms
21,856 KB |
testcase_02 | AC | 11 ms
21,856 KB |
testcase_03 | AC | 20 ms
21,856 KB |
testcase_04 | AC | 33 ms
21,860 KB |
testcase_05 | AC | 32 ms
21,860 KB |
testcase_06 | AC | 39 ms
21,860 KB |
testcase_07 | AC | 39 ms
21,864 KB |
testcase_08 | AC | 46 ms
21,876 KB |
testcase_09 | AC | 51 ms
21,864 KB |
testcase_10 | AC | 49 ms
21,872 KB |
testcase_11 | AC | 229 ms
22,064 KB |
testcase_12 | AC | 369 ms
22,068 KB |
testcase_13 | AC | 232 ms
22,056 KB |
testcase_14 | AC | 81 ms
21,928 KB |
testcase_15 | AC | 280 ms
22,016 KB |
testcase_16 | AC | 507 ms
22,076 KB |
testcase_17 | AC | 114 ms
21,940 KB |
testcase_18 | AC | 599 ms
22,108 KB |
testcase_19 | AC | 243 ms
22,016 KB |
testcase_20 | AC | 87 ms
21,928 KB |
testcase_21 | AC | 65 ms
21,888 KB |
testcase_22 | AC | 64 ms
21,904 KB |
testcase_23 | AC | 44 ms
21,864 KB |
testcase_24 | AC | 324 ms
22,040 KB |
testcase_25 | AC | 375 ms
22,108 KB |
testcase_26 | AC | 507 ms
22,112 KB |
testcase_27 | AC | 532 ms
22,088 KB |
testcase_28 | AC | 685 ms
22,112 KB |
testcase_29 | AC | 324 ms
22,052 KB |
testcase_30 | AC | 129 ms
21,988 KB |
testcase_31 | AC | 63 ms
21,928 KB |
testcase_32 | AC | 502 ms
22,096 KB |
ソースコード
#include <cstdio> #include <iostream> #include <string> #include <sstream> #include <stack> #include <algorithm> #include <cmath> #include <queue> #include <map> #include <set> #include <cstdlib> #include <bitset> #include <tuple> #include <assert.h> #include <deque> #include <bitset> #include <iomanip> #include <limits> #include <chrono> #include <random> #include <array> #include <unordered_map> #include <functional> #include <complex> template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long MAX = 5100000; const long long INF = 1LL << 60; const long long mod = 1000000007LL; //const long long mod = 998244353LL; using namespace std; typedef unsigned long long ull; typedef long long ll; ll n; vector<ll> a, b, c; bool memo[3050][3050]; bool dp[3050][3050]; bool dfs(ll cur1, ll cur2, ll p) { if (p < 0) return true; if (memo[cur1][cur2]) return dp[cur1][cur2]; bool flag = false; //cout << cur1 << " " << cur2 << " " << p << endl; if (cur1 + 1 <= n && a[cur1 + 1] + b[cur2] >= c[p]) flag |= dfs(cur1 + 1, cur2, p - 1); if (cur2 + 1 <= n && a[cur1] + b[cur2 + 1] >= c[p]) flag |= dfs(cur1, cur2 + 1, p - 1); memo[cur1][cur2] = true; return dp[cur1][cur2] = flag; } int main() { /* cin.tie(nullptr); ios::sync_with_stdio(false); */ scanf("%lld", &n); a.resize(n + 1); for (ll i = 0; i <= n; i++) scanf("%lld", &a[i]); b.resize(n + 1); for (ll i = 0; i <= n; i++) scanf("%lld", &b[i]); c.resize(n); for (ll i = 0; i < n; i++) scanf("%lld", &c[i]);; sort(c.begin(), c.end()); ll left = -1; ll right = n; while (right - left > 1) { ll mid = (left + right) >> 1; for (ll i = 0; i <= 3000; i++)for (ll j = 0; j <= 3000; j++) memo[i][j] = false, dp[i][j] = false; if (dfs(0, 0, mid)) left = mid; else right = mid; } printf("%lld\n", left + 1); return 0; }