답안 #922838

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
922838 2024-02-06T07:40:49 Z vjudge1 Collecting Stamps 3 (JOI20_ho_t3) C++17
0 / 100
1 ms 344 KB
#include <bits/stdc++.h>

using namespace std;
const int N = 212, MOD = 1e9 + 7;

typedef long long ll;

int n,L,t[N],x[N];
pair<int,ll> dp[N][N][2];
void test() {
    cin >> n >> L;
    for(int i = 1;i <= n;i++){
        cin >> x[i];
    }
    for(int i = 1;i <= n;i++){
        cin >> t[i];
    }
    for(int i = 0;i <= n;i++){
        for(int j = 0;j <= n;j++){
            for(int k =0 ;k < 2;k++){
                dp[i][j][k] = {-1e9,-1e18};
            }
        }
    }
    dp[0][0][0] = dp[0][0][1] = {0,0};
    x[n + 1] = L;
    for(int i =0;i <=n;i++)
    {
        for(int j = 0;j <= n;j++){
            if(i + j >= n) break;
            {
                dp[i + 1][j][0] = max({dp[i + 1][j][0], make_pair(
                        dp[i][j][0].first + (-dp[i][j][0].second + x[i + 1] - x[i] <= t[i + 1]),
                        dp[i][j][0].second - x[i + 1] + x[i])});
                dp[i + 1][j][0] = max(dp[i + 1][j][0], make_pair(
                        dp[i][j][1].first + (-dp[i][j][1].second + L - x[n - j + 1] + x[i + 1] <= t[i + 1]),
                        dp[i][j][1].second - (L - x[n - j + 1] + x[i + 1])));
                dp[i + 1][j][1] = max(dp[i + 1][j][1], make_pair(dp[i + 1][j][0].first, dp[i + 1][j][0].second -
                                                                                        (x[i + 1] + L - x[n - j + 1])));

            }
            {
                dp[i][j + 1][1] = max({dp[i][j + 1][1], make_pair(
                        dp[i][j][1].first + (-dp[i][j][1].second + x[n - j + 1] - x[n - j] <= t[n - j]),
                        (dp[i][j][1].second - (x[n - j + 1] - x[n - j])))});
                dp[i][j + 1][1] = max({dp[i][j + 1][1], make_pair(
                        dp[i][j][0].first + (-dp[i][j][0].second + x[i] + L - x[n - j] <= t[n - j + 1]),
                        dp[i][j][0].second - (x[i] + L - x[n - j]))});
                dp[i][j + 1][0] = max(dp[i][j + 1][0], make_pair(dp[i][j + 1][1].first,dp[i][j + 1][1].second - (x[i] + L - x[n - j + 1])));

            }
//            cout << i << ' ' << j << ' ' << dp[i][j][0].first << ' ' << dp[i][j][0].second << ' ' << dp[i][j][1].first << ' ' << dp[i][j][1].second << '\n';
        }
    }
    int res = 0;
    for(int i = 0;i <= n;i++){
        for(int j = 0;j <= n;j++){
            res = max({res,dp[i][j][0].first,dp[i][j][1].first});
        }
    }
    cout << res << '\n';
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    int T = 1;
//    cin >> T;
    while (T--)
        test();
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -