結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー tko919tko919
提出日時 2019-12-13 19:47:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 397 ms / 2,500 ms
コード長 1,043 bytes
コンパイル時間 1,504 ms
コンパイル使用メモリ 171,084 KB
実行使用メモリ 38,884 KB
最終ジャッジ日時 2023-09-09 21:43:34
合計ジャッジ時間 6,984 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 4 ms
6,560 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 3 ms
6,496 KB
testcase_11 AC 217 ms
34,496 KB
testcase_12 AC 226 ms
34,188 KB
testcase_13 AC 196 ms
32,248 KB
testcase_14 AC 29 ms
15,308 KB
testcase_15 AC 112 ms
30,080 KB
testcase_16 AC 200 ms
38,280 KB
testcase_17 AC 50 ms
15,136 KB
testcase_18 AC 376 ms
38,420 KB
testcase_19 AC 149 ms
34,444 KB
testcase_20 AC 33 ms
17,236 KB
testcase_21 AC 12 ms
13,112 KB
testcase_22 AC 21 ms
17,488 KB
testcase_23 AC 4 ms
6,424 KB
testcase_24 AC 227 ms
30,096 KB
testcase_25 AC 305 ms
38,872 KB
testcase_26 AC 306 ms
38,812 KB
testcase_27 AC 219 ms
38,764 KB
testcase_28 AC 397 ms
38,884 KB
testcase_29 AC 211 ms
38,776 KB
testcase_30 AC 139 ms
38,764 KB
testcase_31 AC 109 ms
38,816 KB
testcase_32 AC 257 ms
38,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//template end

int dp[3010][3010];

int main(){
    int n; scanf("%d",&n);
    vector<int> a(n+1),b(n+1),d(n);
    rep(i,0,n+1)scanf("%d",&a[i]);
    rep(i,0,n+1)scanf("%d",&b[i]);
    rep(i,0,n)scanf("%d",&d[i]); sort(ALL(d)); dp[0][0]=inf;
    rep(i,0,n+1)rep(j,0,n+1){
        if(i==0&&j==0)continue;
        int idx=upper_bound(ALL(d),a[i]+b[j])-d.begin()-1,ma=0;
        if(i)chmax(ma,dp[i-1][j]); if(j)chmax(ma,dp[i][j-1]);
        dp[i][j]=min(idx,ma-1);
    }
    int ans=0;
    rep(i,0,n+1)rep(j,0,n+1)if(dp[i][j]>=0)chmax(ans,i+j);
    printf("%d\n",ans);
    return 0;
}
0