Submission #224090

# Submission time Handle Problem Language Result Execution time Memory
224090 2020-04-17T07:52:40 Z SomeoneUnknown Collecting Stamps 3 (JOI20_ho_t3) C++14
100 / 100
193 ms 63992 KB
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n, l;
    scanf("%d %d", &n, &l);
    int dsts[n];
    int ts[n];
    for(int i = 0; i < n; i++){
        scanf("%d", &dsts[i]);
    }
    for(int i = 0; i < n; i++){
        scanf("%d", &ts[i]);
    }
    int sttes[n+1][n+1][n+1][2]; //cstationsV, ccstationsV, stamps, pos
    int lmit = 1000000009;
    //for(int i = 0; i <= n; i++)
    //    for(int j = 0; j <= n; j++) sttes[i][j][0] = lmit;
    for(int i = 0; i <= n; i++)
        for(int j = 0; j <= n; j++)
            for(int k = 0; k <= n; k++)
                sttes[i][j][k][0] = sttes[i][j][k][1] = lmit;
    sttes[0][0][0][0] = sttes[0][0][0][1] = 0;
    int best = 0;
    for(int i = 0; i < n; i++){ //stamp count
        for(int j = 0; j <= n; j++){ //clockwise distance
            for(int k = 0; k <= n; k++){ //counterclockwise distance
                if(j + k >= n) continue;
                int ccd, cccd, ncd, nccd;
                ccd = cccd = 0;
                if(j != 0) ccd = dsts[j-1];
                if(k != 0) cccd = l-dsts[n-k];
                ncd = dsts[j];
                nccd = l-dsts[n-k-1];
                //printf("%d %d %d %d %d %d %d\n", i, j, k, ccd, cccd, ncd, nccd);
                int ctspnt = sttes[i][j][k][0];
                int cctspnt = sttes[i][j][k][1];
                sttes[i+(ncd-ccd+ctspnt <= ts[j])][j+1][k][0] = min(sttes[i+(ncd-ccd+ctspnt <= ts[j])][j+1][k][0], ctspnt+ncd-ccd);
                if(sttes[i+1][j+1][k][0] < lmit){
                    best = i+1;
                    //printf("%d %d %d %d %d %d\n", i+1, j+1, k, 0, sttes[i+1][j+1][k][0], sttes[i][j][k][0]);
                }
                sttes[i+(nccd+ccd+ctspnt <= ts[n-k-1])][j][k+1][1] = min(sttes[i+(nccd+ccd+ctspnt <= ts[n-k-1])][j][k+1][1], nccd+ccd+ctspnt);
                if(sttes[i+1][j][k+1][1] < lmit){
                    best = i+1;
                    //printf("%d %d %d %d %d\n", i+1, j, k+1, 1, sttes[i+1][j][k+1][1]);
                }
                sttes[i+(nccd-cccd+cctspnt <= ts[n-k-1])][j][k+1][1] = min(sttes[i+(nccd-cccd+cctspnt <= ts[n-k-1])][j][k+1][1], nccd-cccd+cctspnt);
                if(sttes[i+1][j][k+1][1] < lmit){
                    best = i+1;
                    //printf("%d %d %d %d %d\n", i+1, j, k+1, 1, sttes[i+1][j][k+1][1]);
                }
                sttes[i+(ncd+cccd+cctspnt <= ts[j])][j+1][k][0] = min(sttes[i+(ncd+cccd+cctspnt <= ts[j])][j+1][k][0], ncd+cccd+cctspnt);
                if(sttes[i+1][j+1][k][0] < lmit){
                    best = i+1;
                    //printf("%d %d %d %d %d\n", i+1, j+1, k, 0, sttes[i+1][j+1][k][0]);
                }
            }
        }
    }
    /*for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++){
            for(int k = 0; k <= n; k++){
                printf("(%d,%d) ", sttes[i][j][k][0], sttes[i][j][k][0]);
            }
            printf("\n");
        }
        printf("\n");
    }//*/
    printf("%d", best);
}

Compilation message

ho_t3.cpp: In function 'int main()':
ho_t3.cpp:6:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &l);
     ~~~~~^~~~~~~~~~~~~~~~~
ho_t3.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &dsts[i]);
         ~~~~~^~~~~~~~~~~~~~~~
ho_t3.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &ts[i]);
         ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 256 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 256 KB Output is correct
11 Correct 4 ms 256 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 5 ms 256 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 256 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 256 KB Output is correct
11 Correct 4 ms 256 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 5 ms 256 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 4 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 8 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 384 KB Output is correct
26 Correct 4 ms 384 KB Output is correct
27 Correct 4 ms 256 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 6 ms 384 KB Output is correct
31 Correct 5 ms 384 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 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 256 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 256 KB Output is correct
11 Correct 4 ms 256 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 5 ms 256 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 131 ms 45952 KB Output is correct
19 Correct 68 ms 21880 KB Output is correct
20 Correct 29 ms 8576 KB Output is correct
21 Correct 62 ms 19968 KB Output is correct
22 Correct 90 ms 29440 KB Output is correct
23 Correct 23 ms 6784 KB Output is correct
24 Correct 18 ms 4736 KB Output is correct
25 Correct 24 ms 6656 KB Output is correct
26 Correct 9 ms 1792 KB Output is correct
27 Correct 24 ms 7040 KB Output is correct
28 Correct 16 ms 4352 KB Output is correct
29 Correct 25 ms 7296 KB Output is correct
30 Correct 19 ms 5096 KB Output is correct
31 Correct 23 ms 6656 KB Output is correct
32 Correct 12 ms 2688 KB Output is correct
33 Correct 23 ms 6656 KB Output is correct
34 Correct 8 ms 1568 KB Output is correct
35 Correct 22 ms 6400 KB Output is correct
36 Correct 10 ms 2304 KB Output is correct
37 Correct 24 ms 7040 KB Output is correct
38 Correct 12 ms 2944 KB Output is correct
39 Correct 26 ms 7424 KB Output is correct
40 Correct 14 ms 3456 KB Output is correct
41 Correct 191 ms 62968 KB Output is correct
42 Correct 105 ms 34816 KB Output is correct
43 Correct 190 ms 62980 KB Output is correct
44 Correct 98 ms 34176 KB Output is correct
45 Correct 189 ms 62968 KB Output is correct
46 Correct 106 ms 34844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 256 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 256 KB Output is correct
11 Correct 4 ms 256 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 5 ms 256 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 4 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 8 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 384 KB Output is correct
26 Correct 4 ms 384 KB Output is correct
27 Correct 4 ms 256 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 6 ms 384 KB Output is correct
31 Correct 5 ms 384 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 4 ms 384 KB Output is correct
36 Correct 131 ms 45952 KB Output is correct
37 Correct 68 ms 21880 KB Output is correct
38 Correct 29 ms 8576 KB Output is correct
39 Correct 62 ms 19968 KB Output is correct
40 Correct 90 ms 29440 KB Output is correct
41 Correct 23 ms 6784 KB Output is correct
42 Correct 18 ms 4736 KB Output is correct
43 Correct 24 ms 6656 KB Output is correct
44 Correct 9 ms 1792 KB Output is correct
45 Correct 24 ms 7040 KB Output is correct
46 Correct 16 ms 4352 KB Output is correct
47 Correct 25 ms 7296 KB Output is correct
48 Correct 19 ms 5096 KB Output is correct
49 Correct 23 ms 6656 KB Output is correct
50 Correct 12 ms 2688 KB Output is correct
51 Correct 23 ms 6656 KB Output is correct
52 Correct 8 ms 1568 KB Output is correct
53 Correct 22 ms 6400 KB Output is correct
54 Correct 10 ms 2304 KB Output is correct
55 Correct 24 ms 7040 KB Output is correct
56 Correct 12 ms 2944 KB Output is correct
57 Correct 26 ms 7424 KB Output is correct
58 Correct 14 ms 3456 KB Output is correct
59 Correct 191 ms 62968 KB Output is correct
60 Correct 105 ms 34816 KB Output is correct
61 Correct 190 ms 62980 KB Output is correct
62 Correct 98 ms 34176 KB Output is correct
63 Correct 189 ms 62968 KB Output is correct
64 Correct 106 ms 34844 KB Output is correct
65 Correct 162 ms 54136 KB Output is correct
66 Correct 143 ms 47552 KB Output is correct
67 Correct 136 ms 44416 KB Output is correct
68 Correct 118 ms 39424 KB Output is correct
69 Correct 161 ms 53240 KB Output is correct
70 Correct 150 ms 49920 KB Output is correct
71 Correct 152 ms 50688 KB Output is correct
72 Correct 154 ms 51548 KB Output is correct
73 Correct 141 ms 46072 KB Output is correct
74 Correct 124 ms 41600 KB Output is correct
75 Correct 145 ms 48256 KB Output is correct
76 Correct 177 ms 59256 KB Output is correct
77 Correct 178 ms 59264 KB Output is correct
78 Correct 122 ms 40312 KB Output is correct
79 Correct 128 ms 42240 KB Output is correct
80 Correct 173 ms 57592 KB Output is correct
81 Correct 124 ms 43000 KB Output is correct
82 Correct 141 ms 46840 KB Output is correct
83 Correct 187 ms 62976 KB Output is correct
84 Correct 155 ms 50040 KB Output is correct
85 Correct 163 ms 56572 KB Output is correct
86 Correct 165 ms 54912 KB Output is correct
87 Correct 139 ms 48256 KB Output is correct
88 Correct 191 ms 63872 KB Output is correct
89 Correct 192 ms 63992 KB Output is correct
90 Correct 147 ms 49024 KB Output is correct
91 Correct 193 ms 63992 KB Output is correct
92 Correct 193 ms 63848 KB Output is correct
93 Correct 183 ms 62072 KB Output is correct