結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー ngtkanangtkana
提出日時 2020-04-13 23:26:04
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,267 ms / 2,500 ms
コード長 1,088 bytes
コンパイル時間 2,638 ms
コンパイル使用メモリ 214,432 KB
実行使用メモリ 74,056 KB
最終ジャッジ日時 2024-04-08 11:33:32
合計ジャッジ時間 14,168 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 4 ms
6,676 KB
testcase_09 AC 3 ms
6,676 KB
testcase_10 AC 3 ms
6,676 KB
testcase_11 AC 436 ms
53,320 KB
testcase_12 AC 417 ms
54,184 KB
testcase_13 AC 369 ms
48,056 KB
testcase_14 AC 45 ms
9,472 KB
testcase_15 AC 404 ms
37,720 KB
testcase_16 AC 816 ms
67,468 KB
testcase_17 AC 53 ms
11,360 KB
testcase_18 AC 603 ms
70,752 KB
testcase_19 AC 664 ms
53,736 KB
testcase_20 AC 117 ms
13,652 KB
testcase_21 AC 34 ms
7,576 KB
testcase_22 AC 76 ms
12,336 KB
testcase_23 AC 6 ms
6,676 KB
testcase_24 AC 294 ms
40,184 KB
testcase_25 AC 665 ms
74,056 KB
testcase_26 AC 628 ms
74,056 KB
testcase_27 AC 1,267 ms
74,028 KB
testcase_28 AC 626 ms
74,056 KB
testcase_29 AC 931 ms
73,968 KB
testcase_30 AC 647 ms
73,856 KB
testcase_31 AC 578 ms
73,728 KB
testcase_32 AC 1,028 ms
74,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using ld=long double;
template<class T>using numr=std::numeric_limits<T>;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n;std::cin>>n;
    std::vector<lint>a(n+1),b(n+1),d(n);
    for(lint&x:a)std::cin>>x;
    for(lint&x:b)std::cin>>x;
    for(lint&x:d)std::cin>>x;
    std::sort(ALL(d));
    std::map<std::tuple<lint,lint,lint>,lint>map;
    auto ok=[&](lint c)->bool{
        std::vector<std::vector<lint>>dp(n+1,std::vector<lint>(n+1,-1));
        auto dfs=[&](auto&&f,lint i,lint j)->bool{
            lint&x=dp.at(i).at(j);
            if(x!=-1)return x;
            lint k=c-i-j;
            return x=k==0
                ||d.at(k-1)<=a.at(i+1)+b.at(j)&&f(f,i+1,j)
                ||d.at(k-1)<=a.at(i)+b.at(j+1)&&f(f,i,j+1);
        };
        return dfs(dfs,0,0);
    };
    lint l=0,r=n+1;
    while(1<r-l){
        lint c=(l+r)/2;
        (ok(c)?l:r)=c;
    }
    std::cout<<l<<'\n';
}
0