結果
| 問題 |
No.949 飲酒プログラミングコンテスト
|
| コンテスト | |
| ユーザー |
risujiroh
|
| 提出日時 | 2019-12-12 00:10:54 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 187 ms / 2,500 ms |
| コード長 | 1,110 bytes |
| コンパイル時間 | 2,011 ms |
| コンパイル使用メモリ | 175,752 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-24 08:08:41 |
| 合計ジャッジ時間 | 4,611 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 29 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<int> a(n + 1);
for (auto&& e : a) {
cin >> e;
}
vector<int> b(n + 1);
for (auto&& e : b) {
cin >> e;
}
vector<int> d(n);
for (auto&& e : d) {
cin >> e;
}
sort(begin(d), end(d));
auto chk = [&](int m) {
vector<int> c(begin(d), begin(d) + m);
reverse(begin(c), end(c));
vector< bitset<3001> > dp(m + 1);
dp[0][0] = true;
for (int x = 0; x <= m; ++x) {
for (int y = 0; x + y <= m; ++y) {
if (not dp[x][y]) {
continue;
}
if (x + y < m and a[x + 1] + b[y] >= c[x + y]) {
dp[x + 1][y] = true;
}
if (x + y < m and a[x] + b[y + 1] >= c[x + y]) {
dp[x][y + 1] = true;
}
}
}
for (int x = 0; x <= m; ++x) {
if (dp[x][m - x]) {
return true;
}
}
return false;
};
int ok = 0, ng = n + 1;
while (ng - ok > 1) {
int mid = (ok + ng) / 2;
(chk(mid) ? ok : ng) = mid;
}
cout << ok << '\n';
}
risujiroh