結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー ngtkana
提出日時 2020-04-13 23:21:52
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
MLE  
実行時間 -
コード長 958 bytes
コンパイル時間 3,043 ms
コンパイル使用メモリ 207,796 KB
最終ジャッジ日時 2025-01-09 18:19:40
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 22 TLE * 5 MLE * 2
権限があれば一括ダウンロードができます

ソースコード

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=[&](auto&&f,lint i,lint j,lint k)->bool{
        if(auto it=map.find(std::tuple(i,j,k));it!=map.end())return it->second;
        return map[std::tuple(i,j,k)]=k==0
            ||d.at(k-1)<=a.at(i+1)+b.at(j)&&f(f,i+1,j,k-1)
            ||d.at(k-1)<=a.at(i)+b.at(j+1)&&f(f,i,j+1,k-1);
    };
    lint l=0,r=n+1;
    while(1<r-l){
        lint c=(l+r)/2;
        (ok(ok,0,0,c)?l:r)=c;
    }
    std::cout<<l<<'\n';
}
0