結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー ShibuyapShibuyap
提出日時 2020-08-03 05:08:54
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 182 ms / 2,500 ms
コード長 1,437 bytes
コンパイル時間 2,130 ms
コンパイル使用メモリ 202,376 KB
実行使用メモリ 38,516 KB
最終ジャッジ日時 2023-09-29 13:17:56
合計ジャッジ時間 5,854 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 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 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 110 ms
27,564 KB
testcase_12 AC 116 ms
28,420 KB
testcase_13 AC 93 ms
25,252 KB
testcase_14 AC 13 ms
6,440 KB
testcase_15 AC 53 ms
16,468 KB
testcase_16 AC 114 ms
27,792 KB
testcase_17 AC 15 ms
7,280 KB
testcase_18 AC 161 ms
36,928 KB
testcase_19 AC 48 ms
17,420 KB
testcase_20 AC 11 ms
6,160 KB
testcase_21 AC 3 ms
4,380 KB
testcase_22 AC 5 ms
4,472 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 77 ms
21,868 KB
testcase_25 AC 167 ms
37,436 KB
testcase_26 AC 182 ms
38,392 KB
testcase_27 AC 135 ms
34,364 KB
testcase_28 AC 164 ms
38,516 KB
testcase_29 AC 77 ms
23,172 KB
testcase_30 AC 20 ms
12,404 KB
testcase_31 AC 8 ms
12,148 KB
testcase_32 AC 126 ms
34,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    ll a[n+2], b[n+2], d[n+1];
    rep(i,n+1) cin >> a[i];
    rep(i,n+1) cin >> b[i];
    rep(i,n) cin >> d[i];
    a[n+1] = -1001001001;
    b[n+1] = -1001001001;
    d[n] = 1001001001;
    n++;

    sort(d,d+n);

    int l = 0;
    int r = n;

    while(l+1<r){
        int m = (l+r)/2;
        int dp[m][m+1];
        rep(i,m)rep(j,m+1)dp[i][j] = 0;
        rep(i,m){
            if(i == 0){
                if(a[1]+b[0] >= d[m-1]){
                    dp[0][1] = 1;
                }
                if(a[0]+b[1] >= d[m-1]){
                    dp[0][0] = 1;
                }
            }else{
                rep(j,i+2){
                    if(a[j]+b[i+1-j] < d[m-1-i]) continue;
                    if(i-j>=0 && dp[i-1][j] == 1) dp[i][j] = 1;
                    if(j>0 && dp[i-1][j-1] == 1) dp[i][j] = 1;
                }
            }
        }
        int ok = 0;
        rep(j,m+1){
            if(dp[m-1][j] == 1){
                ok = 1;
                break;
            }
        }
        if(ok) l = m;
        else r = m;
    }

    cout << l << endl;
    return 0;
}
 
 
0