Submission #481355

# Submission time Handle Problem Language Result Execution time Memory
481355 2021-10-20T12:48:21 Z Rainbowbunny Collecting Stamps 3 (JOI20_ho_t3) C++17
15 / 100
1469 ms 141992 KB
#include <bits/stdc++.h>
using namespace std;

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

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

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

signed 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 <long long, 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';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 588 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 844 KB Output is correct
7 Correct 1 ms 588 KB Output is correct
8 Correct 1 ms 716 KB Output is correct
9 Correct 1 ms 844 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 844 KB Output is correct
13 Correct 1 ms 844 KB Output is correct
14 Correct 0 ms 460 KB Output is correct
15 Correct 1 ms 592 KB Output is correct
16 Correct 1 ms 844 KB Output is correct
17 Correct 1 ms 844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 588 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 844 KB Output is correct
7 Correct 1 ms 588 KB Output is correct
8 Correct 1 ms 716 KB Output is correct
9 Correct 1 ms 844 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 844 KB Output is correct
13 Correct 1 ms 844 KB Output is correct
14 Correct 0 ms 460 KB Output is correct
15 Correct 1 ms 592 KB Output is correct
16 Correct 1 ms 844 KB Output is correct
17 Correct 1 ms 844 KB Output is correct
18 Correct 1 ms 972 KB Output is correct
19 Correct 1 ms 716 KB Output is correct
20 Correct 1 ms 844 KB Output is correct
21 Correct 1 ms 972 KB Output is correct
22 Correct 1 ms 588 KB Output is correct
23 Correct 1 ms 1100 KB Output is correct
24 Incorrect 1 ms 972 KB Output isn't correct
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 588 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 844 KB Output is correct
7 Correct 1 ms 588 KB Output is correct
8 Correct 1 ms 716 KB Output is correct
9 Correct 1 ms 844 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 844 KB Output is correct
13 Correct 1 ms 844 KB Output is correct
14 Correct 0 ms 460 KB Output is correct
15 Correct 1 ms 592 KB Output is correct
16 Correct 1 ms 844 KB Output is correct
17 Correct 1 ms 844 KB Output is correct
18 Correct 866 ms 111336 KB Output is correct
19 Correct 411 ms 66944 KB Output is correct
20 Correct 120 ms 35640 KB Output is correct
21 Correct 316 ms 63304 KB Output is correct
22 Correct 559 ms 84292 KB Output is correct
23 Correct 133 ms 30496 KB Output is correct
24 Correct 36 ms 23516 KB Output is correct
25 Correct 122 ms 29908 KB Output is correct
26 Correct 15 ms 11092 KB Output is correct
27 Correct 145 ms 31168 KB Output is correct
28 Correct 37 ms 21552 KB Output is correct
29 Correct 115 ms 30976 KB Output is correct
30 Correct 38 ms 24512 KB Output is correct
31 Correct 110 ms 29372 KB Output is correct
32 Correct 36 ms 15832 KB Output is correct
33 Correct 104 ms 29180 KB Output is correct
34 Correct 13 ms 10444 KB Output is correct
35 Correct 38 ms 28244 KB Output is correct
36 Correct 18 ms 13708 KB Output is correct
37 Correct 40 ms 29972 KB Output is correct
38 Correct 36 ms 17052 KB Output is correct
39 Correct 43 ms 31232 KB Output is correct
40 Correct 25 ms 18572 KB Output is correct
41 Correct 1451 ms 141920 KB Output is correct
42 Correct 49 ms 87492 KB Output is correct
43 Correct 1379 ms 141860 KB Output is correct
44 Correct 55 ms 86412 KB Output is correct
45 Correct 1469 ms 141992 KB Output is correct
46 Correct 56 ms 87456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 588 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 844 KB Output is correct
7 Correct 1 ms 588 KB Output is correct
8 Correct 1 ms 716 KB Output is correct
9 Correct 1 ms 844 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 844 KB Output is correct
13 Correct 1 ms 844 KB Output is correct
14 Correct 0 ms 460 KB Output is correct
15 Correct 1 ms 592 KB Output is correct
16 Correct 1 ms 844 KB Output is correct
17 Correct 1 ms 844 KB Output is correct
18 Correct 1 ms 972 KB Output is correct
19 Correct 1 ms 716 KB Output is correct
20 Correct 1 ms 844 KB Output is correct
21 Correct 1 ms 972 KB Output is correct
22 Correct 1 ms 588 KB Output is correct
23 Correct 1 ms 1100 KB Output is correct
24 Incorrect 1 ms 972 KB Output isn't correct
25 Halted 0 ms 0 KB -