結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー nanophoto12nanophoto12
提出日時 2020-01-02 14:50:07
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,820 bytes
コンパイル時間 1,229 ms
コンパイル使用メモリ 131,568 KB
実行使用メモリ 4,676 KB
最終ジャッジ日時 2023-08-14 18:27:39
合計ジャッジ時間 4,206 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 55 ms
4,376 KB
testcase_16 AC 110 ms
4,428 KB
testcase_17 AC 18 ms
4,380 KB
testcase_18 AC 151 ms
4,600 KB
testcase_19 AC 58 ms
4,380 KB
testcase_20 AC 13 ms
4,376 KB
testcase_21 AC 4 ms
4,376 KB
testcase_22 WA -
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 74 ms
4,376 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 128 ms
4,376 KB
testcase_28 AC 153 ms
4,384 KB
testcase_29 WA -
testcase_30 AC 34 ms
4,376 KB
testcase_31 AC 20 ms
4,380 KB
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<char,char> pcc;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> t3;

#define rep(i,a) for(ll i = 0;i < a;i++)

template <class T>
void cmax(T& a, const T b){a=max(a,b);}

int main(void) {
    ll n;
    cin >> n;
    vector<ll> as(n+1);
    vector<ll> bs(n+1);
    vector<ll> ds(n);
    rep(i,n+1) cin >> as[i];
    rep(i,n+1) cin >> bs[i];
    rep(i,n) cin >> ds[i];
    sort(ds.begin(), ds.end(), std::greater<ll>());
    ll left = -1;
    ll right = n + 1;
    while(right - left > 1)
    {
        ll middle = left + right;
        middle /= 2;
        vector<vector<bool>> dp(n+1,vector<bool>(n+1, false));
        dp[0][0] = true;
        for(int i = 0; i < n;i++){
            dp[i+1][0] = dp[i][0] && (as[i+1] + bs[0] >= ds[n - middle + i]);
            dp[0][i+1] = dp[0][i] && (as[0] + bs[i+1] >= ds[n - middle + i]);
        }
        for(int i = 0;i < n;i++){
            for(int j = 0; j + i < n && n - middle + i + j < n;j++){
                dp[i+1][j+1] = (dp[i][j+1] | dp[i+1][j]) && (as[i+1] + bs[j+1] >= ds[n - middle + i + j]);
            }
        }
        bool ok = false;
        for(int i = 0; middle-i >=0 && i <= n;i++){
            if(dp[middle-i][0 + i]){
                ok = true;
                break;
            }
        }
        if(ok){
            left = middle;
        }
        else{
            right = middle;
        }
    }
    cout << left << endl;
    return 0;
}

0