結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー TAISA_TAISA_
提出日時 2019-12-15 13:14:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,566 bytes
コンパイル時間 1,690 ms
コンパイル使用メモリ 172,368 KB
実行使用メモリ 38,668 KB
最終ジャッジ日時 2023-09-15 15:31:29
合計ジャッジ時間 4,411 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 RE -
testcase_06 WA -
testcase_07 RE -
testcase_08 RE -
testcase_09 WA -
testcase_10 AC 2 ms
4,380 KB
testcase_11 RE -
testcase_12 WA -
testcase_13 WA -
testcase_14 RE -
testcase_15 WA -
testcase_16 WA -
testcase_17 RE -
testcase_18 AC 45 ms
36,840 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 RE -
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 26 ms
21,460 KB
testcase_25 WA -
testcase_26 AC 47 ms
38,364 KB
testcase_27 WA -
testcase_28 AC 49 ms
38,364 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 45 ms
38,416 KB
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n), b(n), d(n), i1(n + 1), i2(n + 1);
    for (int i = 0; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i <= n; i++) {
        cin >> b[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> d[i];
    }
    sort(all(d));
    reverse(all(d));
    for (int i = 1; i <= n; i++) {
        if (a[i1[i - 1]] - a[i1[i - 1] + 1] < b[i2[i - 1]] - b[i2[i - 1] + 1]) {
            i1[i] = i1[i - 1] + 1;
            i2[i] = i2[i - 1];
        } else {
            i2[i] = i2[i - 1] + 1;
            i1[i] = i1[i - 1];
        }
        // cout << i1[i] << " " << i2[i] << endl;
    }
    vector<vector<int>> dp(n + 1, vector<int>(n + 1));
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= n; j++) {
            dp[i + 1][j] |= dp[i][j];
            if (j > 0) {
                if (a[i1[j]] + b[i2[j]] >= d[i]) {
                    dp[i + 1][j] |= dp[i][j - 1];
                }
            }
        }
    }
    int res = 0;
    for (int i = 0; i <= n; i++) {
        if (dp[n][i]) {
            chmax(res, i);
        }
    }
    cout << res << endl;
}
0