結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー zekezeke
提出日時 2019-12-16 16:03:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 3,234 bytes
コンパイル時間 1,006 ms
コンパイル使用メモリ 102,692 KB
実行使用メモリ 144,328 KB
最終ジャッジ日時 2023-09-15 17:46:28
合計ジャッジ時間 7,589 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 140 ms
71,732 KB
testcase_16 AC 253 ms
131,132 KB
testcase_17 AC 38 ms
19,200 KB
testcase_18 RE -
testcase_19 AC 188 ms
103,832 KB
testcase_20 AC 39 ms
23,684 KB
testcase_21 AC 14 ms
11,820 KB
testcase_22 AC 28 ms
21,048 KB
testcase_23 AC 4 ms
4,832 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 274 ms
144,016 KB
testcase_28 AC 325 ms
144,036 KB
testcase_29 AC 266 ms
143,968 KB
testcase_30 AC 211 ms
144,016 KB
testcase_31 RE -
testcase_32 AC 303 ms
144,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <math.h>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
unsigned long long MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    V ken(n + 1);
    V koo(n + 1);
    V score(n);
    rep(i, n + 1) cin >> ken[i];
    rep(i, n + 1) cin >> koo[i];
    rep(i, n) cin >> score[i];
    sort(all(score));
    //    rep(i,n)cout<<score[i]<<" ";
    // cout<<endl;
    vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, 0));
    //   cout<<score[0]<<endl;
    VV reg(n+1,V(n+1));
    
    rep(i, n + 1)
    {
        rep(j, n + 1)
        {
            //  cout<<ken[i]<<" "<<koo[j]<<" "<<score[i+j-1]<<" ";
            if (i + j > n)
                continue;
            if (i == 0 && j == 0){
                dp[i][j] = 1e18;
                reg[0][0]=1e18;
                continue;
            }
            ll k = upper_bound(all(score), ken[i] + koo[j]) - score.begin();
          //  cout<<k<<endl;
            if(k==0){
                reg[i][j]=-1;
                continue;
            }
            if (i == 0 && dp[i][j - 1]){
                chmin(k,reg[i][j-1]-1);
                reg[i][j]=k;
                if(k<=0)continue;
                dp[i][j] = score[k-1];
            }else if (j == 0){
                chmin(k,reg[i-1][j]-1);
                reg[i][j]=k;
                if(k<=0)continue;
                dp[i][j] = score[k-1];
               // if(i==1)cout<<score[]<<endl;
            }else if (dp[i][j - 1] || dp[i - 1][j]){
              //  if(i==6&&j==1)cout<<k<<" "<<ken[i]<<" "<<koo[j]<<" "<<endl;
                k=min(k,max(reg[i][j-1]-1,reg[i-1][j]-1));
                reg[i][j]=k;
                if(k<=0)continue;
                dp[i][j] = score[k-1];
            }
        }
    }
    ll res = 0;
    rep(i, n + 1)
    {
        rep(j, n + 1)
        {
       //     cout << dp[i][j] << " ";
            if (dp[i][j])
                chmax(res, (ll)i + j);
        }
    //    cout << endl;
    }
    cout << res << endl;
}
0