Submission #201562

# Submission time Handle Problem Language Result Execution time Memory
201562 2020-02-11T05:57:09 Z qkxwsm JJOOII 2 (JOI20_ho_t2) C++14
0 / 100
5 ms 760 KB
#include <bits/stdc++.h>

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
    if (a > b) a = b;
}

template<class T, class U>
void ckmax(T &a, U b)
{
    if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define SZ(x) ((int) (x).size())
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

const int MAXN = 213;
const int INF = 1000000007;
const ll LLINF = 2696969696969696969ll;

int N;
ll L;
pll arr[MAXN];
ll dp[MAXN][MAXN][2][MAXN];
int ans;

int32_t main()
{
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(4);
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> N >> L;
    FOR(i, 0, N)
    {
        cin >> arr[i].fi;
    }
    FOR(i, 0, N)
    {
        cin >> arr[i].se;
    }
    arr[N] = {L, 0};
    //dp[how many left we've been][how many right we've been][where are we?][# collected] = time
    FOR(i, 0, N + 1)
    {
        FOR(j, 0, N + 1)
        {
            FOR(k, 0, 2)
            {
                FOR(m, 0, N + 1)
                {
                    dp[i][j][k][m] = LLINF;
                }
            }
        }
    }
    dp[0][0][1][0] = 0;
    FOR(i, 0, N + 1)
    {
        FOR(j, 0, N + 1 - i)
        {
            FOR(k, 0, 2)
            {
                FOR(m, 0, N + 1)
                {
                    if (dp[i][j][k][m] >= LLINF) continue;
                    ckmax(ans, m);
                    if (i + j == N) continue;
                    //head left.
                    ll nt; int nm;
                    if (k) //you are currently at arr[N - j].fi
                    {
                        //try to go to arr[i].fi
                        nt = dp[i][j][k][m] + (L - arr[N - j].fi + arr[i].fi);
                        nm = m + (nt <= arr[i].se);
                        ckmin(dp[i + 1][j][0][nm], nt);
                        //try to go to arr[N - j - 1].fi
                        nt = dp[i][j][k][m] + (arr[N - j].fi - arr[N - j - 1].fi);
                        nm = m + (nt <= arr[N - j - 1].se);
                        ckmin(dp[i][j + 1][1][nm], nt);
                    }
                    else //you are currently at arr[i - 1].fi
                    {
                        //try to go to arr[i].fi
                        nt = dp[i][j][k][m] + (arr[i].fi - arr[i - 1].fi);
                        nm = m + (nt <= arr[i].se);
                        ckmin(dp[i + 1][j][0][nm], nt);
                        //try to go to arr[N - j - 1].fi
                        nt = dp[i][j][k][m] + (arr[i - 1].fi + L - arr[N - j - 1].fi);
                        nm = m + (nt <= arr[N - j - 1].se);
                        ckmin(dp[i][j + 1][1][nm], nt);
                    }
                }
            }
        }
    }
    cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 760 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 760 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 760 KB Output isn't correct
2 Halted 0 ms 0 KB -