답안 #968716

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
968716 2024-04-23T23:11:06 Z raphaelp Collecting Stamps 3 (JOI20_ho_t3) C++14
15 / 100
528 ms 440228 KB
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, L;
    cin >> N >> L;
    vector<pair<int, int>> Tab(N);
    for (int i = 0; i < N; i++)
        cin >> Tab[i].first;
    for (int i = 0; i < N; i++)
        cin >> Tab[i].second;
    sort(Tab.begin(), Tab.end());
    vector<vector<vector<vector<int>>>> dp(N, vector<vector<vector<int>>>(N, vector<vector<int>>(N + 2, vector<int>(2, 1234567890))));
    int maxx = 0;
    dp[0][0][(Tab[0].first <= Tab[0].second) ? 1 : 0][0] = Tab[0].first;
    dp[N - 1][N - 1][(L - Tab[N - 1].first <= Tab[N - 1].second) ? 1 : 0][1] = L - Tab[N - 1].first;
    for (int i = 0; i < N; i++)
    {
        for (int left = 0; left < N; left++)
        {
            int right = (left + N - i) % N;
            for (int nb = 0; nb <= N; nb++)
            {
                if (nb > i + 1)
                    continue;
                if (min(dp[left][right][nb][0], dp[left][right][nb][1]) == 1234567890)
                    continue;
                maxx = max(maxx, nb);
                int next = (left + 1) % N, dist = (Tab[left].first < Tab[next].first) ? Tab[next].first - Tab[left].first : Tab[next].first + L - Tab[left].first;
                dp[next][right][(dp[left][right][nb][0] + dist > Tab[next].second) ? nb : nb + 1][0] = min(dp[left][right][nb][0] + dist, dp[next][right][(dp[left][right][nb][0] + dist > Tab[next].second) ? nb : nb + 1][0]);
                next = (left + 1) % N, dist = (Tab[right].first < Tab[next].first) ? Tab[next].first - Tab[right].first : Tab[next].first + L - Tab[right].first;
                dp[next][right][(dp[left][right][nb][1] + dist > Tab[next].second) ? nb : nb + 1][0] = min(dp[left][right][nb][1] + dist, dp[next][right][(dp[left][right][nb][1] + dist > Tab[next].second) ? nb : nb + 1][0]);
                next = (right - 1 + N) % N, dist = (Tab[right].first > Tab[next].first) ? Tab[right].first - Tab[next].first : Tab[right].first + L - Tab[next].first;
                dp[left][next][(dp[left][right][nb][1] + dist > Tab[next].second) ? nb : nb + 1][1] = min(dp[left][right][nb][1] + dist, dp[left][next][(dp[left][right][nb][1] + dist > Tab[next].second) ? nb : nb + 1][1]);
                next = (right - 1 + N) % N, dist = (Tab[left].first > Tab[next].first) ? Tab[left].first - Tab[next].first : Tab[left].first + L - Tab[next].first;
                dp[left][next][(dp[left][right][nb][0] + dist > Tab[next].second) ? nb : nb + 1][1] = min(dp[left][right][nb][0] + dist, dp[left][next][(dp[left][right][nb][0] + dist > Tab[next].second) ? nb : nb + 1][1]);
            }
        }
    }
    cout << maxx;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Incorrect 0 ms 516 KB Output isn't correct
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 459 ms 320992 KB Output is correct
19 Correct 161 ms 151376 KB Output is correct
20 Correct 65 ms 58708 KB Output is correct
21 Correct 148 ms 138792 KB Output is correct
22 Correct 226 ms 205396 KB Output is correct
23 Correct 51 ms 46204 KB Output is correct
24 Correct 36 ms 31928 KB Output is correct
25 Correct 52 ms 44632 KB Output is correct
26 Correct 11 ms 10584 KB Output is correct
27 Correct 52 ms 47708 KB Output is correct
28 Correct 33 ms 28508 KB Output is correct
29 Correct 55 ms 48976 KB Output is correct
30 Correct 38 ms 34136 KB Output is correct
31 Correct 51 ms 44624 KB Output is correct
32 Correct 18 ms 16988 KB Output is correct
33 Correct 50 ms 44760 KB Output is correct
34 Correct 9 ms 9564 KB Output is correct
35 Correct 48 ms 43340 KB Output is correct
36 Correct 15 ms 14048 KB Output is correct
37 Correct 56 ms 47744 KB Output is correct
38 Correct 20 ms 19292 KB Output is correct
39 Correct 57 ms 50556 KB Output is correct
40 Correct 25 ms 22616 KB Output is correct
41 Correct 528 ms 440116 KB Output is correct
42 Correct 332 ms 242772 KB Output is correct
43 Correct 525 ms 440136 KB Output is correct
44 Correct 258 ms 238672 KB Output is correct
45 Correct 475 ms 440228 KB Output is correct
46 Correct 261 ms 242808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Incorrect 0 ms 516 KB Output isn't correct
20 Halted 0 ms 0 KB -