답안 #224040

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
224040 2020-04-17T05:48:40 Z dwsc Collecting Stamps 3 (JOI20_ho_t3) C++14
100 / 100
516 ms 134136 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
int memo[210][210][210][2];
int pos[210],reach[210];
int n,l;
int dp(int left,int right,int num,int side){
    if (num < 0) return 1e18;
    if (left == 0 && right == 0){
        if (num == 0) return 0;
        return 1e18;
    }
    if (memo[left][right][num][side] != -1) return memo[left][right][num][side];
    if (side){
        int mintime = 1e18;
        if (right != 0){
            int temp1 = min(dp(left,right-1,num-1,1)+pos[right]-pos[right-1],dp(left,right-1,num-1,0)+(pos[right]+l-pos[left])%l);
            if (temp1 <= reach[right]) mintime = min(mintime,temp1);
            int temp2 = min(dp(left,right-1,num,1)+pos[right]-pos[right-1],dp(left,right-1,num,0)+(pos[right]+l-pos[left])%l);
            mintime = min(mintime,temp2);
        }
       //if (num == 6)cout << left << " " << right << " " << num << " " << side << " " << mintime << "\n";
        return memo[left][right][num][side] = mintime;
    }
    else{
        int mintime = 1e18;
        if (left != 0){
            int temp1 = min(dp((left+1)%n,right,num-1,1)+(pos[right]+l-pos[left])%l,dp((left+1)%n,right,num-1,0)+(pos[(left+1)%n]+l-pos[left])%l);
            if (temp1 <= reach[left]) mintime = min(mintime,temp1);
            int temp2 = min(dp((left+1)%n,right,num,1)+(pos[right]+l-pos[left])%l,dp((left+1)%n,right,num,0)+(pos[(left+1)%n]+l-pos[left])%l);
            mintime = min(mintime,temp2);
        }
        //if (num == 6)cout << left << " " << right << " " << num << " " << side << " " << mintime << "\n";
        return memo[left][right][num][side] = mintime;
    }
}
main(){
    cin >> n >> l;
    for (int i = 0; i <= n; i++) for (int j = 0; j <= n; j++) for (int k = 0; k <= n; k++) memo[i][j][k][0] = memo[i][j][k][1] = -1;
    for (int i = 1; i <= n; i++) cin >> pos[i];
    for (int i = 1; i <= n; i++) cin >> reach[i];
    n++;
    pos[0] = 0;
    reach[0] = 1e18;
    dp(5,1,3,0);
    int ans = 0;
    for (int i = 1; i < n; i++){
        for (int j = 0; j < n; j++){
            for (int k = j+1; k <= n; k++){
                //cout << j << " " << k%n << "hi\n";
                if (min(dp(k%n,j,i,0),dp(k%n,j,i,1)) != 1e18) ans = i;
            }
        }
    }
    cout << ans;
}

Compilation message

ho_t3.cpp:37:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 512 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 640 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 5 ms 896 KB Output is correct
7 Correct 5 ms 640 KB Output is correct
8 Correct 5 ms 768 KB Output is correct
9 Correct 5 ms 896 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 896 KB Output is correct
13 Correct 5 ms 896 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
15 Correct 5 ms 640 KB Output is correct
16 Correct 5 ms 896 KB Output is correct
17 Correct 5 ms 896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 512 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 640 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 5 ms 896 KB Output is correct
7 Correct 5 ms 640 KB Output is correct
8 Correct 5 ms 768 KB Output is correct
9 Correct 5 ms 896 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 896 KB Output is correct
13 Correct 5 ms 896 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
15 Correct 5 ms 640 KB Output is correct
16 Correct 5 ms 896 KB Output is correct
17 Correct 5 ms 896 KB Output is correct
18 Correct 6 ms 1152 KB Output is correct
19 Correct 5 ms 768 KB Output is correct
20 Correct 6 ms 896 KB Output is correct
21 Correct 5 ms 1152 KB Output is correct
22 Correct 5 ms 640 KB Output is correct
23 Correct 6 ms 1152 KB Output is correct
24 Correct 5 ms 1024 KB Output is correct
25 Correct 5 ms 1152 KB Output is correct
26 Correct 5 ms 1024 KB Output is correct
27 Correct 5 ms 640 KB Output is correct
28 Correct 5 ms 640 KB Output is correct
29 Correct 5 ms 1152 KB Output is correct
30 Correct 5 ms 1152 KB Output is correct
31 Correct 5 ms 1152 KB Output is correct
32 Correct 5 ms 1024 KB Output is correct
33 Correct 5 ms 1152 KB Output is correct
34 Correct 6 ms 1152 KB Output is correct
35 Correct 5 ms 1152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 512 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 640 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 5 ms 896 KB Output is correct
7 Correct 5 ms 640 KB Output is correct
8 Correct 5 ms 768 KB Output is correct
9 Correct 5 ms 896 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 896 KB Output is correct
13 Correct 5 ms 896 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
15 Correct 5 ms 640 KB Output is correct
16 Correct 5 ms 896 KB Output is correct
17 Correct 5 ms 896 KB Output is correct
18 Correct 318 ms 107512 KB Output is correct
19 Correct 159 ms 65272 KB Output is correct
20 Correct 66 ms 34816 KB Output is correct
21 Correct 134 ms 61568 KB Output is correct
22 Correct 210 ms 79992 KB Output is correct
23 Correct 52 ms 29696 KB Output is correct
24 Correct 38 ms 23288 KB Output is correct
25 Correct 53 ms 29056 KB Output is correct
26 Correct 18 ms 11136 KB Output is correct
27 Correct 56 ms 30208 KB Output is correct
28 Correct 34 ms 21664 KB Output is correct
29 Correct 71 ms 30976 KB Output is correct
30 Correct 48 ms 24320 KB Output is correct
31 Correct 53 ms 29184 KB Output is correct
32 Correct 30 ms 15232 KB Output is correct
33 Correct 56 ms 29176 KB Output is correct
34 Correct 16 ms 10368 KB Output is correct
35 Correct 57 ms 28404 KB Output is correct
36 Correct 20 ms 13568 KB Output is correct
37 Correct 55 ms 30208 KB Output is correct
38 Correct 25 ms 16640 KB Output is correct
39 Correct 67 ms 31616 KB Output is correct
40 Correct 31 ms 18560 KB Output is correct
41 Correct 469 ms 132672 KB Output is correct
42 Correct 268 ms 89336 KB Output is correct
43 Correct 516 ms 132680 KB Output is correct
44 Correct 250 ms 88288 KB Output is correct
45 Correct 488 ms 132664 KB Output is correct
46 Correct 243 ms 89464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 512 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 640 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 5 ms 896 KB Output is correct
7 Correct 5 ms 640 KB Output is correct
8 Correct 5 ms 768 KB Output is correct
9 Correct 5 ms 896 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 896 KB Output is correct
13 Correct 5 ms 896 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
15 Correct 5 ms 640 KB Output is correct
16 Correct 5 ms 896 KB Output is correct
17 Correct 5 ms 896 KB Output is correct
18 Correct 6 ms 1152 KB Output is correct
19 Correct 5 ms 768 KB Output is correct
20 Correct 6 ms 896 KB Output is correct
21 Correct 5 ms 1152 KB Output is correct
22 Correct 5 ms 640 KB Output is correct
23 Correct 6 ms 1152 KB Output is correct
24 Correct 5 ms 1024 KB Output is correct
25 Correct 5 ms 1152 KB Output is correct
26 Correct 5 ms 1024 KB Output is correct
27 Correct 5 ms 640 KB Output is correct
28 Correct 5 ms 640 KB Output is correct
29 Correct 5 ms 1152 KB Output is correct
30 Correct 5 ms 1152 KB Output is correct
31 Correct 5 ms 1152 KB Output is correct
32 Correct 5 ms 1024 KB Output is correct
33 Correct 5 ms 1152 KB Output is correct
34 Correct 6 ms 1152 KB Output is correct
35 Correct 5 ms 1152 KB Output is correct
36 Correct 318 ms 107512 KB Output is correct
37 Correct 159 ms 65272 KB Output is correct
38 Correct 66 ms 34816 KB Output is correct
39 Correct 134 ms 61568 KB Output is correct
40 Correct 210 ms 79992 KB Output is correct
41 Correct 52 ms 29696 KB Output is correct
42 Correct 38 ms 23288 KB Output is correct
43 Correct 53 ms 29056 KB Output is correct
44 Correct 18 ms 11136 KB Output is correct
45 Correct 56 ms 30208 KB Output is correct
46 Correct 34 ms 21664 KB Output is correct
47 Correct 71 ms 30976 KB Output is correct
48 Correct 48 ms 24320 KB Output is correct
49 Correct 53 ms 29184 KB Output is correct
50 Correct 30 ms 15232 KB Output is correct
51 Correct 56 ms 29176 KB Output is correct
52 Correct 16 ms 10368 KB Output is correct
53 Correct 57 ms 28404 KB Output is correct
54 Correct 20 ms 13568 KB Output is correct
55 Correct 55 ms 30208 KB Output is correct
56 Correct 25 ms 16640 KB Output is correct
57 Correct 67 ms 31616 KB Output is correct
58 Correct 31 ms 18560 KB Output is correct
59 Correct 469 ms 132672 KB Output is correct
60 Correct 268 ms 89336 KB Output is correct
61 Correct 516 ms 132680 KB Output is correct
62 Correct 250 ms 88288 KB Output is correct
63 Correct 488 ms 132664 KB Output is correct
64 Correct 243 ms 89464 KB Output is correct
65 Correct 456 ms 119760 KB Output is correct
66 Correct 337 ms 109952 KB Output is correct
67 Correct 381 ms 105200 KB Output is correct
68 Correct 316 ms 97120 KB Output is correct
69 Correct 388 ms 118624 KB Output is correct
70 Correct 345 ms 113504 KB Output is correct
71 Correct 340 ms 114816 KB Output is correct
72 Correct 399 ms 116044 KB Output is correct
73 Correct 336 ms 107640 KB Output is correct
74 Correct 290 ms 100552 KB Output is correct
75 Correct 340 ms 111200 KB Output is correct
76 Correct 442 ms 127428 KB Output is correct
77 Correct 385 ms 127352 KB Output is correct
78 Correct 293 ms 98264 KB Output is correct
79 Correct 287 ms 101624 KB Output is correct
80 Correct 423 ms 124920 KB Output is correct
81 Correct 279 ms 102776 KB Output is correct
82 Correct 306 ms 108792 KB Output is correct
83 Correct 474 ms 132668 KB Output is correct
84 Correct 319 ms 113656 KB Output is correct
85 Correct 392 ms 123640 KB Output is correct
86 Correct 345 ms 120952 KB Output is correct
87 Correct 326 ms 111160 KB Output is correct
88 Correct 466 ms 133992 KB Output is correct
89 Correct 450 ms 133880 KB Output is correct
90 Correct 316 ms 112376 KB Output is correct
91 Correct 432 ms 134136 KB Output is correct
92 Correct 440 ms 134008 KB Output is correct
93 Correct 417 ms 131372 KB Output is correct