# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
205324 | 2020-02-28T14:32:24 Z | TadijaSebez | Collecting Stamps 3 (JOI20_ho_t3) | C++11 | 146 ms | 135544 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long const ll inf=9e18; const int N=205; void ckmn(ll &a,ll b){a=min(a,b);} ll dp[N][N][2][N]; int x[N],t[N]; int main(){ int n,L; scanf("%i %i",&n,&L); for(int i=1;i<=n;i++)scanf("%i",&x[i]); for(int i=1;i<=n;i++)scanf("%i",&t[i]); for(int i=0;i<N;i++)for(int j=0;j<N;j++)for(int k=0;k<2;k++)for(int o=0;o<N;o++)dp[i][j][k][o]=inf; dp[0][n+1][0][0]=0; for(int sz=n+1;sz>1;sz--){ for(int i=0;i<=n+1-sz;i++){ int j=i+sz; for(int k=0;k<=n;k++){ if(dp[i][j][0][k]<inf){ ll tme=dp[i][j][0][k]+x[i+1]-x[i]; ckmn(dp[i+1][j][0][k+(tme<=t[i+1])],tme); tme=dp[i][j][0][k]+x[i]+L-x[j-1]; ckmn(dp[i][j-1][1][k+(tme<=t[j-1])],tme); } if(dp[i][j][1][k]<inf){ ll tme=dp[i][j][1][k]+x[i+1]+L-x[j]; ckmn(dp[i+1][j][0][k+(tme<=t[i+1])],tme); tme=dp[i][j][1][k]+x[j]-x[j-1]; ckmn(dp[i][j-1][1][k+(tme<=t[j-1])],tme); } } } } int ans=0; for(int i=0;i<=n;i++)for(int k=1;k<=n;k++)if(dp[i][i+1][0][k]<inf || dp[i][i+1][1][k]<inf)ans=max(ans,k); printf("%i\n",ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 83 ms | 135160 KB | Output is correct |
2 | Correct | 96 ms | 135288 KB | Output is correct |
3 | Correct | 84 ms | 135160 KB | Output is correct |
4 | Correct | 84 ms | 135160 KB | Output is correct |
5 | Correct | 84 ms | 135160 KB | Output is correct |
6 | Correct | 87 ms | 135144 KB | Output is correct |
7 | Correct | 84 ms | 135392 KB | Output is correct |
8 | Correct | 83 ms | 135160 KB | Output is correct |
9 | Correct | 86 ms | 135164 KB | Output is correct |
10 | Correct | 82 ms | 135160 KB | Output is correct |
11 | Correct | 83 ms | 135160 KB | Output is correct |
12 | Correct | 87 ms | 135288 KB | Output is correct |
13 | Correct | 86 ms | 135160 KB | Output is correct |
14 | Correct | 83 ms | 135160 KB | Output is correct |
15 | Correct | 82 ms | 135160 KB | Output is correct |
16 | Correct | 83 ms | 135160 KB | Output is correct |
17 | Correct | 87 ms | 135160 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 83 ms | 135160 KB | Output is correct |
2 | Correct | 96 ms | 135288 KB | Output is correct |
3 | Correct | 84 ms | 135160 KB | Output is correct |
4 | Correct | 84 ms | 135160 KB | Output is correct |
5 | Correct | 84 ms | 135160 KB | Output is correct |
6 | Correct | 87 ms | 135144 KB | Output is correct |
7 | Correct | 84 ms | 135392 KB | Output is correct |
8 | Correct | 83 ms | 135160 KB | Output is correct |
9 | Correct | 86 ms | 135164 KB | Output is correct |
10 | Correct | 82 ms | 135160 KB | Output is correct |
11 | Correct | 83 ms | 135160 KB | Output is correct |
12 | Correct | 87 ms | 135288 KB | Output is correct |
13 | Correct | 86 ms | 135160 KB | Output is correct |
14 | Correct | 83 ms | 135160 KB | Output is correct |
15 | Correct | 82 ms | 135160 KB | Output is correct |
16 | Correct | 83 ms | 135160 KB | Output is correct |
17 | Correct | 87 ms | 135160 KB | Output is correct |
18 | Correct | 83 ms | 135164 KB | Output is correct |
19 | Correct | 86 ms | 135160 KB | Output is correct |
20 | Correct | 85 ms | 135160 KB | Output is correct |
21 | Correct | 84 ms | 135160 KB | Output is correct |
22 | Correct | 87 ms | 135160 KB | Output is correct |
23 | Correct | 84 ms | 135160 KB | Output is correct |
24 | Correct | 83 ms | 135160 KB | Output is correct |
25 | Correct | 83 ms | 135160 KB | Output is correct |
26 | Correct | 85 ms | 135160 KB | Output is correct |
27 | Correct | 81 ms | 135160 KB | Output is correct |
28 | Correct | 90 ms | 135288 KB | Output is correct |
29 | Correct | 84 ms | 135160 KB | Output is correct |
30 | Correct | 84 ms | 135160 KB | Output is correct |
31 | Correct | 106 ms | 135160 KB | Output is correct |
32 | Correct | 82 ms | 135164 KB | Output is correct |
33 | Correct | 84 ms | 135160 KB | Output is correct |
34 | Correct | 83 ms | 135160 KB | Output is correct |
35 | Correct | 87 ms | 135288 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 83 ms | 135160 KB | Output is correct |
2 | Correct | 96 ms | 135288 KB | Output is correct |
3 | Correct | 84 ms | 135160 KB | Output is correct |
4 | Correct | 84 ms | 135160 KB | Output is correct |
5 | Correct | 84 ms | 135160 KB | Output is correct |
6 | Correct | 87 ms | 135144 KB | Output is correct |
7 | Correct | 84 ms | 135392 KB | Output is correct |
8 | Correct | 83 ms | 135160 KB | Output is correct |
9 | Correct | 86 ms | 135164 KB | Output is correct |
10 | Correct | 82 ms | 135160 KB | Output is correct |
11 | Correct | 83 ms | 135160 KB | Output is correct |
12 | Correct | 87 ms | 135288 KB | Output is correct |
13 | Correct | 86 ms | 135160 KB | Output is correct |
14 | Correct | 83 ms | 135160 KB | Output is correct |
15 | Correct | 82 ms | 135160 KB | Output is correct |
16 | Correct | 83 ms | 135160 KB | Output is correct |
17 | Correct | 87 ms | 135160 KB | Output is correct |
18 | Correct | 114 ms | 135160 KB | Output is correct |
19 | Correct | 98 ms | 135160 KB | Output is correct |
20 | Correct | 91 ms | 135160 KB | Output is correct |
21 | Correct | 98 ms | 135124 KB | Output is correct |
22 | Correct | 101 ms | 135160 KB | Output is correct |
23 | Correct | 89 ms | 135160 KB | Output is correct |
24 | Correct | 83 ms | 135160 KB | Output is correct |
25 | Correct | 91 ms | 135160 KB | Output is correct |
26 | Correct | 88 ms | 135160 KB | Output is correct |
27 | Correct | 90 ms | 135160 KB | Output is correct |
28 | Correct | 86 ms | 135136 KB | Output is correct |
29 | Correct | 89 ms | 135160 KB | Output is correct |
30 | Correct | 85 ms | 135240 KB | Output is correct |
31 | Correct | 91 ms | 135288 KB | Output is correct |
32 | Correct | 91 ms | 135160 KB | Output is correct |
33 | Correct | 90 ms | 135160 KB | Output is correct |
34 | Correct | 84 ms | 135288 KB | Output is correct |
35 | Correct | 86 ms | 135160 KB | Output is correct |
36 | Correct | 85 ms | 135160 KB | Output is correct |
37 | Correct | 87 ms | 135160 KB | Output is correct |
38 | Correct | 84 ms | 135152 KB | Output is correct |
39 | Correct | 86 ms | 135160 KB | Output is correct |
40 | Correct | 87 ms | 135288 KB | Output is correct |
41 | Correct | 135 ms | 135544 KB | Output is correct |
42 | Correct | 92 ms | 135160 KB | Output is correct |
43 | Correct | 135 ms | 135124 KB | Output is correct |
44 | Correct | 93 ms | 135160 KB | Output is correct |
45 | Correct | 137 ms | 135288 KB | Output is correct |
46 | Correct | 97 ms | 135160 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 83 ms | 135160 KB | Output is correct |
2 | Correct | 96 ms | 135288 KB | Output is correct |
3 | Correct | 84 ms | 135160 KB | Output is correct |
4 | Correct | 84 ms | 135160 KB | Output is correct |
5 | Correct | 84 ms | 135160 KB | Output is correct |
6 | Correct | 87 ms | 135144 KB | Output is correct |
7 | Correct | 84 ms | 135392 KB | Output is correct |
8 | Correct | 83 ms | 135160 KB | Output is correct |
9 | Correct | 86 ms | 135164 KB | Output is correct |
10 | Correct | 82 ms | 135160 KB | Output is correct |
11 | Correct | 83 ms | 135160 KB | Output is correct |
12 | Correct | 87 ms | 135288 KB | Output is correct |
13 | Correct | 86 ms | 135160 KB | Output is correct |
14 | Correct | 83 ms | 135160 KB | Output is correct |
15 | Correct | 82 ms | 135160 KB | Output is correct |
16 | Correct | 83 ms | 135160 KB | Output is correct |
17 | Correct | 87 ms | 135160 KB | Output is correct |
18 | Correct | 83 ms | 135164 KB | Output is correct |
19 | Correct | 86 ms | 135160 KB | Output is correct |
20 | Correct | 85 ms | 135160 KB | Output is correct |
21 | Correct | 84 ms | 135160 KB | Output is correct |
22 | Correct | 87 ms | 135160 KB | Output is correct |
23 | Correct | 84 ms | 135160 KB | Output is correct |
24 | Correct | 83 ms | 135160 KB | Output is correct |
25 | Correct | 83 ms | 135160 KB | Output is correct |
26 | Correct | 85 ms | 135160 KB | Output is correct |
27 | Correct | 81 ms | 135160 KB | Output is correct |
28 | Correct | 90 ms | 135288 KB | Output is correct |
29 | Correct | 84 ms | 135160 KB | Output is correct |
30 | Correct | 84 ms | 135160 KB | Output is correct |
31 | Correct | 106 ms | 135160 KB | Output is correct |
32 | Correct | 82 ms | 135164 KB | Output is correct |
33 | Correct | 84 ms | 135160 KB | Output is correct |
34 | Correct | 83 ms | 135160 KB | Output is correct |
35 | Correct | 87 ms | 135288 KB | Output is correct |
36 | Correct | 114 ms | 135160 KB | Output is correct |
37 | Correct | 98 ms | 135160 KB | Output is correct |
38 | Correct | 91 ms | 135160 KB | Output is correct |
39 | Correct | 98 ms | 135124 KB | Output is correct |
40 | Correct | 101 ms | 135160 KB | Output is correct |
41 | Correct | 89 ms | 135160 KB | Output is correct |
42 | Correct | 83 ms | 135160 KB | Output is correct |
43 | Correct | 91 ms | 135160 KB | Output is correct |
44 | Correct | 88 ms | 135160 KB | Output is correct |
45 | Correct | 90 ms | 135160 KB | Output is correct |
46 | Correct | 86 ms | 135136 KB | Output is correct |
47 | Correct | 89 ms | 135160 KB | Output is correct |
48 | Correct | 85 ms | 135240 KB | Output is correct |
49 | Correct | 91 ms | 135288 KB | Output is correct |
50 | Correct | 91 ms | 135160 KB | Output is correct |
51 | Correct | 90 ms | 135160 KB | Output is correct |
52 | Correct | 84 ms | 135288 KB | Output is correct |
53 | Correct | 86 ms | 135160 KB | Output is correct |
54 | Correct | 85 ms | 135160 KB | Output is correct |
55 | Correct | 87 ms | 135160 KB | Output is correct |
56 | Correct | 84 ms | 135152 KB | Output is correct |
57 | Correct | 86 ms | 135160 KB | Output is correct |
58 | Correct | 87 ms | 135288 KB | Output is correct |
59 | Correct | 135 ms | 135544 KB | Output is correct |
60 | Correct | 92 ms | 135160 KB | Output is correct |
61 | Correct | 135 ms | 135124 KB | Output is correct |
62 | Correct | 93 ms | 135160 KB | Output is correct |
63 | Correct | 137 ms | 135288 KB | Output is correct |
64 | Correct | 97 ms | 135160 KB | Output is correct |
65 | Correct | 123 ms | 135160 KB | Output is correct |
66 | Correct | 122 ms | 135160 KB | Output is correct |
67 | Correct | 119 ms | 135160 KB | Output is correct |
68 | Correct | 113 ms | 135160 KB | Output is correct |
69 | Correct | 124 ms | 135160 KB | Output is correct |
70 | Correct | 134 ms | 135160 KB | Output is correct |
71 | Correct | 121 ms | 135160 KB | Output is correct |
72 | Correct | 133 ms | 135160 KB | Output is correct |
73 | Correct | 110 ms | 135160 KB | Output is correct |
74 | Correct | 126 ms | 135160 KB | Output is correct |
75 | Correct | 123 ms | 135160 KB | Output is correct |
76 | Correct | 134 ms | 135160 KB | Output is correct |
77 | Correct | 126 ms | 135192 KB | Output is correct |
78 | Correct | 121 ms | 135160 KB | Output is correct |
79 | Correct | 115 ms | 135160 KB | Output is correct |
80 | Correct | 131 ms | 135160 KB | Output is correct |
81 | Correct | 129 ms | 135160 KB | Output is correct |
82 | Correct | 119 ms | 135160 KB | Output is correct |
83 | Correct | 146 ms | 135160 KB | Output is correct |
84 | Correct | 112 ms | 135164 KB | Output is correct |
85 | Correct | 130 ms | 135160 KB | Output is correct |
86 | Correct | 128 ms | 135288 KB | Output is correct |
87 | Correct | 137 ms | 135160 KB | Output is correct |
88 | Correct | 141 ms | 135260 KB | Output is correct |
89 | Correct | 132 ms | 135160 KB | Output is correct |
90 | Correct | 98 ms | 135160 KB | Output is correct |
91 | Correct | 143 ms | 135160 KB | Output is correct |
92 | Correct | 131 ms | 135160 KB | Output is correct |
93 | Correct | 97 ms | 135144 KB | Output is correct |