답안 #481350

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
481350 2021-10-20T12:44:12 Z Rainbowbunny Collecting Stamps 3 (JOI20_ho_t3) C++17
15 / 100
1300 ms 75792 KB
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 205;
const int INF = 2e9 + 5;

int n, l, ans;
int X[MAXN], t[MAXN];
int dp[MAXN][MAXN][MAXN][2];

int f(int x)
{
    return min(x, l - x);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    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 <= n; k++)
            {
                for(int h = 0; h < 2; h++)
                {
                    dp[i][j][k][h] = INF;
                }
            }
        }
    }
    dp[0][0][0][0] = 0;
    priority_queue <tuple <int, int, int, int, int> > pq;
    pq.push(make_tuple(0, 0, 0, 0, 0));
    while(pq.empty() == false)
    {
        int d, l, r, k, h;
        tie(d, l, r, k, h) = pq.top();
        pq.pop();
        d = -d;
        ans = max(ans, k);
        if(d == dp[l][r][k][h])
        {
            int prv = l - 1;
            if(prv == -1)
            {
                prv = n;
            }
            
            if(prv != r)
            {
                int dist = d + f(abs(X[prv] - (h ? X[r] : X[l])));
                if(dist <= t[prv] and prv != 0)
                {
                    if(dp[prv][r][k + 1][0] > dist)
                    {
                        dp[prv][r][k + 1][0] = dist;
                        pq.push(make_tuple(-dist, prv, r, k + 1, 0));
                    }
                }
                else
                {
                    if(dp[prv][r][k][0] > dist)
                    {
                        dp[prv][r][k][0] = dist;
                        pq.push(make_tuple(-dist, prv, r, k, 0));
                    }
                }
            }
            int nxt = r + 1;
            if(nxt != l)
            {
                int dist = d + f(abs(X[nxt] - (h ? X[r] : X[l])));
                if(dist <= t[nxt] and nxt != 0)
                {
                    if(dp[l][nxt][k + 1][1] > dist)
                    {
                        dp[l][nxt][k + 1][1] = dist;
                        pq.push(make_tuple(-dist, l, nxt, k + 1, 1));
                    }
                }
                else
                {
                    if(dp[l][nxt][k][1] > dist)
                    {
                        dp[l][nxt][k][1] = dist;
                        pq.push(make_tuple(-dist, l, nxt, k, 1));
                    }
                }
            }
        }
    }
    cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 588 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 588 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 572 KB Output is correct
13 Correct 1 ms 588 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 1 ms 588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 588 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 588 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 572 KB Output is correct
13 Correct 1 ms 588 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 1 ms 588 KB Output is correct
18 Correct 1 ms 716 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 1 ms 588 KB Output is correct
21 Correct 1 ms 716 KB Output is correct
22 Correct 1 ms 460 KB Output is correct
23 Correct 1 ms 716 KB Output is correct
24 Incorrect 1 ms 588 KB Output isn't correct
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 588 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 588 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 572 KB Output is correct
13 Correct 1 ms 588 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 1 ms 588 KB Output is correct
18 Correct 770 ms 58196 KB Output is correct
19 Correct 379 ms 34912 KB Output is correct
20 Correct 113 ms 18748 KB Output is correct
21 Correct 275 ms 33080 KB Output is correct
22 Correct 507 ms 44816 KB Output is correct
23 Correct 124 ms 16140 KB Output is correct
24 Correct 33 ms 12416 KB Output is correct
25 Correct 111 ms 15804 KB Output is correct
26 Correct 12 ms 5964 KB Output is correct
27 Correct 130 ms 16484 KB Output is correct
28 Correct 31 ms 11228 KB Output is correct
29 Correct 106 ms 16200 KB Output is correct
30 Correct 30 ms 12936 KB Output is correct
31 Correct 101 ms 15240 KB Output is correct
32 Correct 29 ms 8456 KB Output is correct
33 Correct 95 ms 15296 KB Output is correct
34 Correct 11 ms 5580 KB Output is correct
35 Correct 26 ms 14564 KB Output is correct
36 Correct 15 ms 7296 KB Output is correct
37 Correct 34 ms 15580 KB Output is correct
38 Correct 30 ms 9096 KB Output is correct
39 Correct 35 ms 16132 KB Output is correct
40 Correct 20 ms 9772 KB Output is correct
41 Correct 1298 ms 75792 KB Output is correct
42 Correct 32 ms 44328 KB Output is correct
43 Correct 1245 ms 75628 KB Output is correct
44 Correct 32 ms 43820 KB Output is correct
45 Correct 1300 ms 75548 KB Output is correct
46 Correct 36 ms 44332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 588 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 588 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 572 KB Output is correct
13 Correct 1 ms 588 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 1 ms 588 KB Output is correct
18 Correct 1 ms 716 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 1 ms 588 KB Output is correct
21 Correct 1 ms 716 KB Output is correct
22 Correct 1 ms 460 KB Output is correct
23 Correct 1 ms 716 KB Output is correct
24 Incorrect 1 ms 588 KB Output isn't correct
25 Halted 0 ms 0 KB -