Submission #230144

# Submission time Handle Problem Language Result Execution time Memory
230144 2020-05-08T17:17:28 Z Andrei_Cotor Collecting Stamps 3 (JOI20_ho_t3) C++11
100 / 100
92 ms 67004 KB
#include<iostream>
#include<algorithm>

using namespace std;

int Poz[205],T[205];
long long Dp[2][205][205][205];

void propag(int tip, int i, int j, int nr, long long time)
{
    if(tip==0)
    {
        if(T[i]>=time)
            nr++;
    }
    else if(T[j]>=time)
    {
        nr++;
    }

    Dp[tip][i][j][nr]=min(Dp[tip][i][j][nr],time);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n,l;
    cin>>n>>l;
    
    for(int i=1; i<=n; i++)
        cin>>Poz[i];
    Poz[n+1]=l;

    for(int i=1; i<=n; i++)
        cin>>T[i];

    for(int i=0; i<2; i++)
    {
        for(int j=0; j<=n; j++)
        {
            for(int k=j+1; k<=n+1; k++)
            {
                for(int l=0; l<=j+n-k+1; l++)
                {
                    Dp[i][j][k][l]=1e18;
                }
            }
        }
    }

    Dp[0][0][n+1][0]=Dp[1][0][n+1][0]=0;
    for(int i=0; i<n; i++)
    {
        for(int j=n+1; j>=i+2; j--)
        {
            for(int k=0; k<=i+n-j+1; k++)
            {
                if(Dp[0][i][j][k]==1e18 && Dp[1][i][j][k]==1e18)
                    continue;

                propag(0,i+1,j,k,Dp[0][i][j][k]+Poz[i+1]-Poz[i]);
                propag(1,i,j-1,k,Dp[0][i][j][k]+Poz[i]+l-Poz[j-1]);
                propag(1,i,j-1,k,Dp[1][i][j][k]+Poz[j]-Poz[j-1]);
                propag(0,i+1,j,k,Dp[1][i][j][k]+l-Poz[j]+Poz[i+1]);
            }
        }
    }

    int rez=0;
    for(int i=0; i<=n; i++)
    {
        for(int j=rez+1; j<=n; j++)
        {
            if(Dp[0][i][i+1][j]!=1e18 || Dp[1][i][i+1][j]!=1e18)
                rez=j;
        }
    }
    cout<<rez<<"\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 512 KB Output is correct
4 Correct 4 ms 512 KB Output is correct
5 Correct 4 ms 512 KB Output is correct
6 Correct 5 ms 768 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 640 KB Output is correct
9 Correct 5 ms 768 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 768 KB Output is correct
13 Correct 5 ms 768 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
15 Correct 5 ms 512 KB Output is correct
16 Correct 5 ms 768 KB Output is correct
17 Correct 5 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 512 KB Output is correct
4 Correct 4 ms 512 KB Output is correct
5 Correct 4 ms 512 KB Output is correct
6 Correct 5 ms 768 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 640 KB Output is correct
9 Correct 5 ms 768 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 768 KB Output is correct
13 Correct 5 ms 768 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
15 Correct 5 ms 512 KB Output is correct
16 Correct 5 ms 768 KB Output is correct
17 Correct 5 ms 768 KB Output is correct
18 Correct 5 ms 768 KB Output is correct
19 Correct 5 ms 640 KB Output is correct
20 Correct 5 ms 768 KB Output is correct
21 Correct 5 ms 768 KB Output is correct
22 Correct 5 ms 512 KB Output is correct
23 Correct 5 ms 896 KB Output is correct
24 Correct 5 ms 768 KB Output is correct
25 Correct 5 ms 768 KB Output is correct
26 Correct 5 ms 768 KB Output is correct
27 Correct 5 ms 512 KB Output is correct
28 Correct 5 ms 512 KB Output is correct
29 Correct 5 ms 896 KB Output is correct
30 Correct 5 ms 896 KB Output is correct
31 Correct 5 ms 768 KB Output is correct
32 Correct 5 ms 768 KB Output is correct
33 Correct 5 ms 896 KB Output is correct
34 Correct 5 ms 896 KB Output is correct
35 Correct 5 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 512 KB Output is correct
4 Correct 4 ms 512 KB Output is correct
5 Correct 4 ms 512 KB Output is correct
6 Correct 5 ms 768 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 640 KB Output is correct
9 Correct 5 ms 768 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 768 KB Output is correct
13 Correct 5 ms 768 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
15 Correct 5 ms 512 KB Output is correct
16 Correct 5 ms 768 KB Output is correct
17 Correct 5 ms 768 KB Output is correct
18 Correct 57 ms 53888 KB Output is correct
19 Correct 35 ms 32896 KB Output is correct
20 Correct 18 ms 17920 KB Output is correct
21 Correct 32 ms 31104 KB Output is correct
22 Correct 45 ms 40192 KB Output is correct
23 Correct 18 ms 15360 KB Output is correct
24 Correct 12 ms 12032 KB Output is correct
25 Correct 17 ms 14976 KB Output is correct
26 Correct 8 ms 6016 KB Output is correct
27 Correct 18 ms 15616 KB Output is correct
28 Correct 12 ms 11264 KB Output is correct
29 Correct 18 ms 16000 KB Output is correct
30 Correct 13 ms 12672 KB Output is correct
31 Correct 16 ms 14976 KB Output is correct
32 Correct 10 ms 8064 KB Output is correct
33 Correct 16 ms 14976 KB Output is correct
34 Correct 7 ms 5632 KB Output is correct
35 Correct 14 ms 14720 KB Output is correct
36 Correct 9 ms 7168 KB Output is correct
37 Correct 15 ms 15616 KB Output is correct
38 Correct 10 ms 8704 KB Output is correct
39 Correct 15 ms 16256 KB Output is correct
40 Correct 10 ms 9728 KB Output is correct
41 Correct 80 ms 66296 KB Output is correct
42 Correct 31 ms 45048 KB Output is correct
43 Correct 82 ms 66304 KB Output is correct
44 Correct 31 ms 44288 KB Output is correct
45 Correct 81 ms 66300 KB Output is correct
46 Correct 31 ms 44928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 512 KB Output is correct
4 Correct 4 ms 512 KB Output is correct
5 Correct 4 ms 512 KB Output is correct
6 Correct 5 ms 768 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 640 KB Output is correct
9 Correct 5 ms 768 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 768 KB Output is correct
13 Correct 5 ms 768 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
15 Correct 5 ms 512 KB Output is correct
16 Correct 5 ms 768 KB Output is correct
17 Correct 5 ms 768 KB Output is correct
18 Correct 5 ms 768 KB Output is correct
19 Correct 5 ms 640 KB Output is correct
20 Correct 5 ms 768 KB Output is correct
21 Correct 5 ms 768 KB Output is correct
22 Correct 5 ms 512 KB Output is correct
23 Correct 5 ms 896 KB Output is correct
24 Correct 5 ms 768 KB Output is correct
25 Correct 5 ms 768 KB Output is correct
26 Correct 5 ms 768 KB Output is correct
27 Correct 5 ms 512 KB Output is correct
28 Correct 5 ms 512 KB Output is correct
29 Correct 5 ms 896 KB Output is correct
30 Correct 5 ms 896 KB Output is correct
31 Correct 5 ms 768 KB Output is correct
32 Correct 5 ms 768 KB Output is correct
33 Correct 5 ms 896 KB Output is correct
34 Correct 5 ms 896 KB Output is correct
35 Correct 5 ms 896 KB Output is correct
36 Correct 57 ms 53888 KB Output is correct
37 Correct 35 ms 32896 KB Output is correct
38 Correct 18 ms 17920 KB Output is correct
39 Correct 32 ms 31104 KB Output is correct
40 Correct 45 ms 40192 KB Output is correct
41 Correct 18 ms 15360 KB Output is correct
42 Correct 12 ms 12032 KB Output is correct
43 Correct 17 ms 14976 KB Output is correct
44 Correct 8 ms 6016 KB Output is correct
45 Correct 18 ms 15616 KB Output is correct
46 Correct 12 ms 11264 KB Output is correct
47 Correct 18 ms 16000 KB Output is correct
48 Correct 13 ms 12672 KB Output is correct
49 Correct 16 ms 14976 KB Output is correct
50 Correct 10 ms 8064 KB Output is correct
51 Correct 16 ms 14976 KB Output is correct
52 Correct 7 ms 5632 KB Output is correct
53 Correct 14 ms 14720 KB Output is correct
54 Correct 9 ms 7168 KB Output is correct
55 Correct 15 ms 15616 KB Output is correct
56 Correct 10 ms 8704 KB Output is correct
57 Correct 15 ms 16256 KB Output is correct
58 Correct 10 ms 9728 KB Output is correct
59 Correct 80 ms 66296 KB Output is correct
60 Correct 31 ms 45048 KB Output is correct
61 Correct 82 ms 66304 KB Output is correct
62 Correct 31 ms 44288 KB Output is correct
63 Correct 81 ms 66300 KB Output is correct
64 Correct 31 ms 44928 KB Output is correct
65 Correct 68 ms 59896 KB Output is correct
66 Correct 63 ms 55040 KB Output is correct
67 Correct 58 ms 52736 KB Output is correct
68 Correct 54 ms 48768 KB Output is correct
69 Correct 67 ms 59384 KB Output is correct
70 Correct 72 ms 56952 KB Output is correct
71 Correct 60 ms 57464 KB Output is correct
72 Correct 75 ms 57984 KB Output is correct
73 Correct 49 ms 53888 KB Output is correct
74 Correct 62 ms 50432 KB Output is correct
75 Correct 59 ms 55680 KB Output is correct
76 Correct 78 ms 63616 KB Output is correct
77 Correct 69 ms 63608 KB Output is correct
78 Correct 57 ms 49280 KB Output is correct
79 Correct 57 ms 50936 KB Output is correct
80 Correct 76 ms 62456 KB Output is correct
81 Correct 58 ms 51584 KB Output is correct
82 Correct 53 ms 54400 KB Output is correct
83 Correct 75 ms 66424 KB Output is correct
84 Correct 55 ms 56832 KB Output is correct
85 Correct 59 ms 61944 KB Output is correct
86 Correct 59 ms 60540 KB Output is correct
87 Correct 62 ms 55680 KB Output is correct
88 Correct 91 ms 66944 KB Output is correct
89 Correct 82 ms 67004 KB Output is correct
90 Correct 39 ms 56192 KB Output is correct
91 Correct 92 ms 66944 KB Output is correct
92 Correct 80 ms 66940 KB Output is correct
93 Correct 43 ms 65656 KB Output is correct