結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー chocoruskchocorusk
提出日時 2019-12-12 00:12:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 210 ms / 2,500 ms
コード長 1,502 bytes
コンパイル時間 937 ms
コンパイル使用メモリ 111,376 KB
実行使用メモリ 12,628 KB
最終ジャッジ日時 2023-09-06 13:35:13
合計ジャッジ時間 4,550 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
12,316 KB
testcase_01 AC 5 ms
12,464 KB
testcase_02 AC 4 ms
12,368 KB
testcase_03 AC 5 ms
12,384 KB
testcase_04 AC 5 ms
12,320 KB
testcase_05 AC 7 ms
12,316 KB
testcase_06 AC 8 ms
12,372 KB
testcase_07 AC 8 ms
12,320 KB
testcase_08 AC 8 ms
12,624 KB
testcase_09 AC 8 ms
12,316 KB
testcase_10 AC 8 ms
12,312 KB
testcase_11 AC 93 ms
12,336 KB
testcase_12 AC 119 ms
12,344 KB
testcase_13 AC 92 ms
12,560 KB
testcase_14 AC 20 ms
12,504 KB
testcase_15 AC 86 ms
12,404 KB
testcase_16 AC 166 ms
12,420 KB
testcase_17 AC 28 ms
12,344 KB
testcase_18 AC 197 ms
12,340 KB
testcase_19 AC 102 ms
12,624 KB
testcase_20 AC 25 ms
12,332 KB
testcase_21 AC 13 ms
12,328 KB
testcase_22 AC 20 ms
12,324 KB
testcase_23 AC 8 ms
12,332 KB
testcase_24 AC 103 ms
12,340 KB
testcase_25 AC 152 ms
12,336 KB
testcase_26 AC 169 ms
12,420 KB
testcase_27 AC 179 ms
12,400 KB
testcase_28 AC 210 ms
12,456 KB
testcase_29 AC 136 ms
12,396 KB
testcase_30 AC 99 ms
12,404 KB
testcase_31 AC 87 ms
12,628 KB
testcase_32 AC 175 ms
12,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;
    cin>>n;
    int a[3030], b[3030], d[3030];
    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);
    int l=0, r=n+1;
    while(r-l>1){
        int m=(l+r)/2;
        if(m==0){
            l=m;
            continue;
        }
        bool dp[3030][3030]={};
        dp[0][0]=1;
        for(int i=0; i<=n; i++){
            for(int j=0; j<=n; j++){
                if(!dp[i][j] || m-i-j-1<0) continue;
                if(i<n && a[i+1]+b[j]>=d[m-i-j-1]){
                    dp[i+1][j]=1;
                }
                if(j<n && a[i]+b[j+1]>=d[m-i-j-1]){
                    dp[i][j+1]=1;
                }
            }
        }
        bool ok=0;
        for(int i=0; i<=m; i++){
            if(dp[i][m-i]){
                ok=1;
                break;
            }
        }
        if(ok) l=m;
        else r=m;
    }
    cout<<l<<endl;
	return 0;
}
0