結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー kyort0nkyort0n
提出日時 2019-12-12 00:06:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 101 ms / 2,500 ms
コード長 1,411 bytes
コンパイル時間 1,543 ms
コンパイル使用メモリ 167,200 KB
実行使用メモリ 12,464 KB
最終ジャッジ日時 2023-09-06 13:34:32
合計ジャッジ時間 3,903 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
12,400 KB
testcase_01 AC 6 ms
12,164 KB
testcase_02 AC 4 ms
12,108 KB
testcase_03 AC 6 ms
12,120 KB
testcase_04 AC 7 ms
12,124 KB
testcase_05 AC 8 ms
12,116 KB
testcase_06 AC 8 ms
12,368 KB
testcase_07 AC 8 ms
12,120 KB
testcase_08 AC 9 ms
12,132 KB
testcase_09 AC 8 ms
12,220 KB
testcase_10 AC 9 ms
12,148 KB
testcase_11 AC 61 ms
12,172 KB
testcase_12 AC 66 ms
12,176 KB
testcase_13 AC 57 ms
12,292 KB
testcase_14 AC 15 ms
12,136 KB
testcase_15 AC 40 ms
12,280 KB
testcase_16 AC 69 ms
12,212 KB
testcase_17 AC 18 ms
12,188 KB
testcase_18 AC 93 ms
12,352 KB
testcase_19 AC 38 ms
12,204 KB
testcase_20 AC 16 ms
12,228 KB
testcase_21 AC 11 ms
12,200 KB
testcase_22 AC 12 ms
12,140 KB
testcase_23 AC 9 ms
12,112 KB
testcase_24 AC 53 ms
12,152 KB
testcase_25 AC 89 ms
12,172 KB
testcase_26 AC 94 ms
12,168 KB
testcase_27 AC 76 ms
12,296 KB
testcase_28 AC 101 ms
12,168 KB
testcase_29 AC 51 ms
12,464 KB
testcase_30 AC 23 ms
12,208 KB
testcase_31 AC 15 ms
12,192 KB
testcase_32 AC 73 ms
12,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//Happy Birthday @rian_tkb !!
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
ll N;
ll A[3005], B[3005], D[3005];
bool dp[3005][3005];

bool f(int num) {
    for(int i = 0; i <= 3000; i++) {
        for(int j = 0; j <= 3000; j++) {
            dp[i][j] = false;
        }
    }
    dp[0][0] = true;
    for(int i = 0; i <= num; i++) {
        for(int j = 0; j <= num - i; j++) {
            bool can = false;
            if(i > 0 && dp[i-1][j]) can = true;
            if(j > 0 && dp[i][j-1]) can = true;
            if(!can) continue;
            if(D[num-i-j] <= A[i] + B[j]) dp[i][j] = true;
        }
    }
    for(int i = 0; i <= num; i++) {
        if(dp[i][num-i]) return true;
    }
    return false;
}

int main() {
    cin >> N;
    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(D, D + N);
    ll ok = 0;
    ll ng = N + 1;
    while(ng - ok > 1) {
        ll mid = (ok + ng) / 2;
        if(f(mid)) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
    return 0;
}
0