結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー tarattata1tarattata1
提出日時 2019-12-12 01:04:19
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 428 ms / 2,500 ms
コード長 1,650 bytes
コンパイル時間 2,696 ms
コンパイル使用メモリ 78,396 KB
実行使用メモリ 38,292 KB
最終ジャッジ日時 2023-09-06 13:40:20
合計ジャッジ時間 5,875 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3 ms
5,952 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 3 ms
5,848 KB
testcase_11 AC 147 ms
33,716 KB
testcase_12 AC 206 ms
33,720 KB
testcase_13 AC 164 ms
31,672 KB
testcase_14 AC 14 ms
14,468 KB
testcase_15 AC 100 ms
27,552 KB
testcase_16 AC 297 ms
37,816 KB
testcase_17 AC 21 ms
14,628 KB
testcase_18 AC 371 ms
37,820 KB
testcase_19 AC 110 ms
33,756 KB
testcase_20 AC 21 ms
16,748 KB
testcase_21 AC 9 ms
12,372 KB
testcase_22 AC 14 ms
16,740 KB
testcase_23 AC 4 ms
5,952 KB
testcase_24 AC 140 ms
29,612 KB
testcase_25 AC 333 ms
38,228 KB
testcase_26 AC 327 ms
38,228 KB
testcase_27 AC 345 ms
38,232 KB
testcase_28 AC 428 ms
38,272 KB
testcase_29 AC 190 ms
38,292 KB
testcase_30 AC 100 ms
38,268 KB
testcase_31 AC 88 ms
38,240 KB
testcase_32 AC 336 ms
38,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;

int dp[3005][3005];

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    vector<int> a(n+1),b(n+1),d(n);
    int i,j;
    for(i=0; i<n+1; i++) {
        scanf("%d", &a[i]);
    }
    for(i=0; i<n+1; i++) {
        scanf("%d", &b[i]);
    }
    for(i=0; i<n; i++) {
        scanf("%d", &d[i]);
    }
    sort(d.begin(), d.end());

    int l=0, r=n+1;
    while(r-l>1) {
        int m=(l+r)/2;
        
        for(i=0; i<=n; i++) {
            for(j=0; j<=n; j++) {
                dp[i][j]=0;
            }
        }
        dp[0][0]=1;
        int k;
        for(k=1; k<=m; k++) {
            int found=0;
            for(i=0; i<=k; i++) {
                int j=k-i;
                if((i>0 && dp[i-1][j])||(j>0 && dp[i][j-1])) {
                    if(a[i]+b[j]>=d[m-k]) {
                        dp[i][j]=1;
                        found=1;
                    }
                }
            }
            if(found==0)
                break;
        }
        if(k==m+1) {   //ok
            l=m;
        }
        else {
            r=m;
        }
    }
    printf("%d\n", l);

    return 0;
}
0