結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー ttttan2ttttan2
提出日時 2019-12-12 13:20:07
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 473 ms / 2,500 ms
コード長 2,257 bytes
コンパイル時間 1,728 ms
コンパイル使用メモリ 155,104 KB
実行使用メモリ 73,892 KB
最終ジャッジ日時 2023-09-07 04:59:43
合計ジャッジ時間 8,746 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 328 ms
53,152 KB
testcase_12 AC 340 ms
54,124 KB
testcase_13 AC 300 ms
47,928 KB
testcase_14 AC 39 ms
9,452 KB
testcase_15 AC 164 ms
37,608 KB
testcase_16 AC 298 ms
67,248 KB
testcase_17 AC 48 ms
11,612 KB
testcase_18 AC 421 ms
70,520 KB
testcase_19 AC 217 ms
53,620 KB
testcase_20 AC 45 ms
13,852 KB
testcase_21 AC 14 ms
7,752 KB
testcase_22 AC 27 ms
12,352 KB
testcase_23 AC 3 ms
4,376 KB
testcase_24 AC 191 ms
40,036 KB
testcase_25 AC 467 ms
73,892 KB
testcase_26 AC 473 ms
73,860 KB
testcase_27 AC 329 ms
73,796 KB
testcase_28 AC 451 ms
73,792 KB
testcase_29 AC 317 ms
73,816 KB
testcase_30 AC 192 ms
73,804 KB
testcase_31 AC 144 ms
73,804 KB
testcase_32 AC 395 ms
73,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll n;cin>>n;
    ll a[n+1],b[n+1];
    rep(i,0,n+1)cin>>a[i];
    
    rep(i,0,n+1)cin>>b[i];
    ll na=0,nb=0;
    vector<ll> v(n),w;
    rep(i,0,n){
    	cin>>v[i];
    }
    w=v;
    
    sort(w.begin(),w.end());
    sort(v.begin(),v.end(),greater<ll>());
    ll dp[n+1][n+1];
    rep(i,0,n+1)rep(j,0,n+1)dp[i][j]=inf;
    dp[0][0]=0;
    rep(i,0,n){
    	rep(j,0,n){
    		if(i+j>=n)break;
    		ll y=upper_bound(w.begin(),w.end(),a[i+1]+b[j])-w.begin();
    		y--;
    		y=n-1-y;
    		
    		if(dp[i][j]>y)y=dp[i][j];
    		y++;
    		dp[i+1][j]=min(dp[i+1][j],y);
    		y=upper_bound(w.begin(),w.end(),b[j+1]+a[i])-w.begin();
    		y--;
    		y=n-1-y;
    		
    		if(dp[i][j]>y)y=dp[i][j];
    		y++;
    		dp[i][j+1]=min(dp[i][j+1],y);
    	
    	}
    }
    ll ans=0;
    rep(i,0,n+1){
    	rep(j,0,n+1){
    		if(dp[i][j]<n+1)ans=max(ans,i+j);
         // cout<<dp[i][j]<<" ";
    	}
      //cout<<endl;
    }
    cout<<ans<<endl;
  
}
0