Submission #228614

# Submission time Handle Problem Language Result Execution time Memory
228614 2020-05-02T07:03:05 Z Ruxandra985 Collecting Stamps 3 (JOI20_ho_t3) C++14
100 / 100
18 ms 1664 KB
#include <bits/stdc++.h>
#define DIMN 210
#define INF 2000000000
using namespace std;
long long v[DIMN] , t[DIMN];
pair <long long , long long> dp[2][DIMN][DIMN];
int main()
{
    FILE *fin = stdin;
    FILE *fout = stdout;
    long long n , l , i , j , curr , poz , timp , urm , sol = 0 , went , j2;
    fscanf (fin,"%lld%lld",&n,&l);

    for (i = 1 ; i <= n ; i++)
        fscanf (fin,"%lld",&v[i]);

    v[n + 1] = l;

    for (i = 1 ; i <= n ; i++)
        fscanf (fin,"%lld",&t[i]);

    for (i = 0 ; i <= n + 1 ; i++){
        for (j = 0 ; j <= n + 1 ; j++){
            dp[0][i][j] = dp[1][i][j] = make_pair(INF , 0);
        }
    }

    dp[1][0][0] = dp[0][0][0] = make_pair(0 , 0);

    for (went = 0 ; went <= n ; went++){

        for (i = 0 ; i <= n && i <= went ; i++){

            j2 = n - (went - i) + 1;
            j = went - i;

            //if (i == 12 && j == 1)
              //  printf ("a");

            /// se presupune ca dp[0/1][i][j] sunt calculate

            /// pt cazul cu 0


            timp = dp[0][i][j].first;
            curr = dp[0][i][j].second;
            /// vreau sa revin in j

            timp = timp + v[i] + l - v[j2];
            poz = v[j2];
            /// sunt inapoi in j, acum o sa ma duc mai departe prin j


            urm = j2;

            while (poz != v[i]){
                timp += poz - v[urm - 1];

                if (t[urm - 1] >= timp)
                    curr++;

                poz = v[urm - 1];
                urm--;

                /// te ai mutat altundeva

                if (dp[1][i][n - urm + 1].second < curr || (dp[1][i][n - urm + 1].first > timp && dp[1][i][n - urm + 1].second == curr)){
                    dp[1][i][n - urm + 1] = make_pair(timp , curr);

                    //if (i == 2 && n - urm + 1 == 4){
                      //  printf ("%lld\n", curr);
                    //}
                }

            }


            /// ----------------------------------------------------------------------


            /// pt cazul cu 1

            timp = dp[1][i][j].first;
            curr = dp[1][i][j].second;
            /// vreau sa revin in i

            timp = timp + v[i] + l - v[j2];
            /// sunt inapoi in i, acum o sa ma duc mai departe prin i


            urm = i;
            poz = v[i];

            while (poz != v[j2]){
                timp += v[urm + 1] - poz;

                if (t[urm + 1] >= timp)
                    curr++;

                poz = v[urm + 1];
                urm++;

                /// te ai mutat altundeva

                if (dp[0][urm][j].second < curr || (dp[0][urm][j].first > timp && dp[0][urm][j].second == curr)){
                    dp[0][urm][j] = make_pair(timp , curr);
                    //if (urm == 2 && j == 7){
                      //  printf ("%lld\n", curr);
                    //}
                }

            }



        }

    }


    for (i = 0 ; i <= n + 1 ; i++){
        for (j = 0 ; j <= n + 1 ; j++){
            if (i + j <= n)
                sol = max(sol , max(dp[0][i][j].second , dp[1][i][j].second));
            //printf ("0 %lld %lld %lld\n" , i , j , dp[0][i][j].second);
            //printf ("1 %lld %lld %lld\n" , i , j , dp[1][i][j].second);
        }
    }


    fprintf (fout,"%lld",sol);

    return 0;
}

Compilation message

ho_t3.cpp: In function 'int main()':
ho_t3.cpp:12:12: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     fscanf (fin,"%lld%lld",&n,&l);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
ho_t3.cpp:15:16: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         fscanf (fin,"%lld",&v[i]);
         ~~~~~~~^~~~~~~~~~~~~~~~~~
ho_t3.cpp:20:16: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         fscanf (fin,"%lld",&t[i]);
         ~~~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 512 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 5 ms 512 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Correct 5 ms 384 KB Output is correct
35 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 9 ms 1536 KB Output is correct
19 Correct 8 ms 1280 KB Output is correct
20 Correct 6 ms 1024 KB Output is correct
21 Correct 7 ms 1280 KB Output is correct
22 Correct 8 ms 1408 KB Output is correct
23 Correct 5 ms 896 KB Output is correct
24 Correct 5 ms 896 KB Output is correct
25 Correct 6 ms 1024 KB Output is correct
26 Correct 5 ms 640 KB Output is correct
27 Correct 6 ms 1024 KB Output is correct
28 Correct 5 ms 896 KB Output is correct
29 Correct 6 ms 896 KB Output is correct
30 Correct 5 ms 896 KB Output is correct
31 Correct 6 ms 896 KB Output is correct
32 Correct 5 ms 768 KB Output is correct
33 Correct 6 ms 896 KB Output is correct
34 Correct 5 ms 640 KB Output is correct
35 Correct 6 ms 896 KB Output is correct
36 Correct 5 ms 768 KB Output is correct
37 Correct 6 ms 896 KB Output is correct
38 Correct 5 ms 768 KB Output is correct
39 Correct 6 ms 1024 KB Output is correct
40 Correct 5 ms 896 KB Output is correct
41 Correct 12 ms 1664 KB Output is correct
42 Correct 8 ms 1408 KB Output is correct
43 Correct 11 ms 1664 KB Output is correct
44 Correct 8 ms 1408 KB Output is correct
45 Correct 11 ms 1664 KB Output is correct
46 Correct 8 ms 1408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 512 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 5 ms 512 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Correct 5 ms 384 KB Output is correct
35 Correct 5 ms 384 KB Output is correct
36 Correct 9 ms 1536 KB Output is correct
37 Correct 8 ms 1280 KB Output is correct
38 Correct 6 ms 1024 KB Output is correct
39 Correct 7 ms 1280 KB Output is correct
40 Correct 8 ms 1408 KB Output is correct
41 Correct 5 ms 896 KB Output is correct
42 Correct 5 ms 896 KB Output is correct
43 Correct 6 ms 1024 KB Output is correct
44 Correct 5 ms 640 KB Output is correct
45 Correct 6 ms 1024 KB Output is correct
46 Correct 5 ms 896 KB Output is correct
47 Correct 6 ms 896 KB Output is correct
48 Correct 5 ms 896 KB Output is correct
49 Correct 6 ms 896 KB Output is correct
50 Correct 5 ms 768 KB Output is correct
51 Correct 6 ms 896 KB Output is correct
52 Correct 5 ms 640 KB Output is correct
53 Correct 6 ms 896 KB Output is correct
54 Correct 5 ms 768 KB Output is correct
55 Correct 6 ms 896 KB Output is correct
56 Correct 5 ms 768 KB Output is correct
57 Correct 6 ms 1024 KB Output is correct
58 Correct 5 ms 896 KB Output is correct
59 Correct 12 ms 1664 KB Output is correct
60 Correct 8 ms 1408 KB Output is correct
61 Correct 11 ms 1664 KB Output is correct
62 Correct 8 ms 1408 KB Output is correct
63 Correct 11 ms 1664 KB Output is correct
64 Correct 8 ms 1408 KB Output is correct
65 Correct 10 ms 1536 KB Output is correct
66 Correct 11 ms 1536 KB Output is correct
67 Correct 10 ms 1536 KB Output is correct
68 Correct 10 ms 1536 KB Output is correct
69 Correct 11 ms 1664 KB Output is correct
70 Correct 10 ms 1536 KB Output is correct
71 Correct 11 ms 1536 KB Output is correct
72 Correct 10 ms 1536 KB Output is correct
73 Correct 10 ms 1536 KB Output is correct
74 Correct 9 ms 1536 KB Output is correct
75 Correct 9 ms 1536 KB Output is correct
76 Correct 18 ms 1664 KB Output is correct
77 Correct 12 ms 1664 KB Output is correct
78 Correct 11 ms 1408 KB Output is correct
79 Correct 9 ms 1536 KB Output is correct
80 Correct 12 ms 1664 KB Output is correct
81 Correct 10 ms 1536 KB Output is correct
82 Correct 9 ms 1536 KB Output is correct
83 Correct 11 ms 1664 KB Output is correct
84 Correct 10 ms 1536 KB Output is correct
85 Correct 13 ms 1536 KB Output is correct
86 Correct 11 ms 1536 KB Output is correct
87 Correct 10 ms 1536 KB Output is correct
88 Correct 13 ms 1664 KB Output is correct
89 Correct 12 ms 1664 KB Output is correct
90 Correct 10 ms 1536 KB Output is correct
91 Correct 12 ms 1664 KB Output is correct
92 Correct 11 ms 1664 KB Output is correct
93 Correct 11 ms 1664 KB Output is correct