Submission #438885

# Submission time Handle Problem Language Result Execution time Memory
438885 2021-06-28T22:30:40 Z Snowfall Collecting Stamps 3 (JOI20_ho_t3) C++14
15 / 100
93 ms 104936 KB
#include<bits/stdc++.h>
using namespace std;
long long arr[205][205][205][2];
int a[205],b[205];
main()
{
	int t,p;
    scanf("%d%d",&t,&p);
    queue<pair<int,pair<int,int> > >q;
    for(int i = 1;i <= t;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i = 1;i <= t;i++)
    {
        scanf("%d",&b[i]);
    }
    for(int i = 0;i <= t;i++)
    {
        for(int j = 0;j <= t;j++)
        {
            for(int k = 0;k <= t;k++)
            {
                for(int l = 0;l < 2;l++)
                arr[i][j][k][l]=1e18;
            }
        }
    }
    a[t+1]=p;
    arr[0][0][0][0]=0;
    arr[0][0][0][1]=0;
    for(int i = 0;i <= t;i++)
    {
        for(int j = 0;j+i <= t;j++)
        {
            for(int k = 0;k <= i+j;k++)
            {
                if(arr[i][j][k][0]+a[i+1]-a[i]<=b[i+1] && i+j+1<=t)
                {
                    arr[i+1][j][k+1][0]=min(arr[i+1][j][k+1][0],arr[i][j][k][0]+a[i+1]-a[i]);
                }
                else
                {
                    arr[i+1][j][k][0]=min(arr[i+1][j][k][0],arr[i][j][k][0]+a[i+1]-a[i]);
                }

                if(arr[i][j][k][1]+a[t-j+1]-a[t-j]<=b[t-j] && i+j+1<=t)
                {
                    arr[i][j+1][k+1][1]=min(arr[i][j+1][k+1][1],arr[i][j][k][1]+a[t-j+1]-a[t-j]);
                }
                else
                {
                    arr[i][j+1][k][1]=min(arr[i][j+1][k][1],arr[i][j][k][1]+a[t-j+1]-a[t-j]);
                }

                if(arr[i][j][k][0]+a[i]+a[t-j+1]-a[t-j]<=b[t-j] && i+j+1<=t)
                {
                    arr[i][j+1][k+1][1]=min(arr[i][j+1][k+1][1],arr[i][j][k][0]+a[i]+a[t-j+1]-a[t-j]);
                }
                else
                {
                    arr[i][j+1][k][1]=min(arr[i][j+1][k][1],arr[i][j][k][0]+a[i]+a[t-j+1]-a[t-j]);
                }

                if(arr[i][j][k][1]+p-a[t-j+1]+a[i+1]<=b[i+1] && i+j+1<=t)
                {
                    arr[i+1][j][k+1][0]=min(arr[i+1][j][k+1][0],arr[i][j][k][1]+p-a[t-j+1]+a[i+1]);
                }
                else
                {
                    arr[i+1][j][k][0]=min(arr[i+1][j][k][0],arr[i][j][k][1]+p-a[t-j+1]+a[i+1]);
                }
            }
        }
    }
    int mx=0;
    for(int i = 0;i <= t;i++)
    {
        for(int j = 0;j+i <= t;j++)
        {
            for(int k = 0;k <= i+j;k++)
            {
                for(int l = 0;l < 2;l++)
                {
                    if(arr[i][j][k][l]!=1e18)
                    mx=max(mx,k);
                }
            }
        }
    }
    printf("%d",mx);
}

Compilation message

ho_t3.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main()
      | ^~~~
ho_t3.cpp: In function 'int main()':
ho_t3.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     scanf("%d%d",&t,&p);
      |     ~~~~~^~~~~~~~~~~~~~
ho_t3.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         scanf("%d",&a[i]);
      |         ~~~~~^~~~~~~~~~~~
ho_t3.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         scanf("%d",&b[i]);
      |         ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 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 588 KB Output is correct
9 Correct 1 ms 844 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 844 KB Output is correct
13 Correct 1 ms 844 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 1 ms 588 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 1 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 588 KB Output is correct
9 Correct 1 ms 844 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 844 KB Output is correct
13 Correct 1 ms 844 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 1 ms 588 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 Correct 1 ms 844 KB Output is correct
25 Correct 1 ms 972 KB Output is correct
26 Correct 2 ms 972 KB Output is correct
27 Correct 1 ms 588 KB Output is correct
28 Correct 1 ms 588 KB Output is correct
29 Correct 1 ms 1100 KB Output is correct
30 Correct 1 ms 1100 KB Output is correct
31 Correct 1 ms 972 KB Output is correct
32 Correct 1 ms 972 KB Output is correct
33 Correct 1 ms 1100 KB Output is correct
34 Correct 1 ms 1100 KB Output is correct
35 Correct 1 ms 1100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 588 KB Output is correct
9 Correct 1 ms 844 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 844 KB Output is correct
13 Correct 1 ms 844 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 1 ms 588 KB Output is correct
16 Correct 1 ms 844 KB Output is correct
17 Correct 1 ms 844 KB Output is correct
18 Correct 93 ms 104936 KB Output is correct
19 Correct 49 ms 63656 KB Output is correct
20 Correct 26 ms 33968 KB Output is correct
21 Correct 52 ms 60100 KB Output is correct
22 Correct 65 ms 77832 KB Output is correct
23 Correct 20 ms 28936 KB Output is correct
24 Correct 15 ms 22604 KB Output is correct
25 Correct 24 ms 28236 KB Output is correct
26 Correct 7 ms 10828 KB Output is correct
27 Correct 20 ms 29444 KB Output is correct
28 Correct 16 ms 21052 KB Output is correct
29 Correct 24 ms 30132 KB Output is correct
30 Correct 18 ms 23724 KB Output is correct
31 Correct 22 ms 28236 KB Output is correct
32 Correct 9 ms 14796 KB Output is correct
33 Incorrect 22 ms 28344 KB Output isn't correct
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 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 588 KB Output is correct
9 Correct 1 ms 844 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 844 KB Output is correct
13 Correct 1 ms 844 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 1 ms 588 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 Correct 1 ms 844 KB Output is correct
25 Correct 1 ms 972 KB Output is correct
26 Correct 2 ms 972 KB Output is correct
27 Correct 1 ms 588 KB Output is correct
28 Correct 1 ms 588 KB Output is correct
29 Correct 1 ms 1100 KB Output is correct
30 Correct 1 ms 1100 KB Output is correct
31 Correct 1 ms 972 KB Output is correct
32 Correct 1 ms 972 KB Output is correct
33 Correct 1 ms 1100 KB Output is correct
34 Correct 1 ms 1100 KB Output is correct
35 Correct 1 ms 1100 KB Output is correct
36 Correct 93 ms 104936 KB Output is correct
37 Correct 49 ms 63656 KB Output is correct
38 Correct 26 ms 33968 KB Output is correct
39 Correct 52 ms 60100 KB Output is correct
40 Correct 65 ms 77832 KB Output is correct
41 Correct 20 ms 28936 KB Output is correct
42 Correct 15 ms 22604 KB Output is correct
43 Correct 24 ms 28236 KB Output is correct
44 Correct 7 ms 10828 KB Output is correct
45 Correct 20 ms 29444 KB Output is correct
46 Correct 16 ms 21052 KB Output is correct
47 Correct 24 ms 30132 KB Output is correct
48 Correct 18 ms 23724 KB Output is correct
49 Correct 22 ms 28236 KB Output is correct
50 Correct 9 ms 14796 KB Output is correct
51 Incorrect 22 ms 28344 KB Output isn't correct
52 Halted 0 ms 0 KB -