답안 #545027

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
545027 2022-04-03T10:39:58 Z Asymmetry Collecting Stamps 3 (JOI20_ho_t3) C++17
100 / 100
52 ms 68160 KB
//Autor: Bartłomiej Czarkowski
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
template<class A,class B>auto&operator<<(ostream&o,pair<A,B>p){return o<<'('<<p.first<<", "<<p.second<<')';}
template<class T>auto operator<<(ostream&o,T x)->decltype(x.end(),o){o<<'{';int i=0;for(auto e:x)o<<(", ")+2*!i++<<e;return o<<'}';}
#define debug(x...) cerr<<"["#x"]: ",[](auto...$){((cerr<<$<<"; "),...);}(x),cerr<<'\n'
#else
#define debug(...) {}
#endif

typedef unsigned int unt;

const int N = 210;
int n, L, odp;
unt X[N];
unt T[N];
unt dp[N][N][N][2];

int main() {
	scanf("%d%d", &n, &L);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &X[i]);
	}
	X[n + 1] = L;
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &T[i]);
	}
	for (int i = 0; i <= n + 1; ++i) {
		for (int j = 0; j <= n + 1; ++j) {
			for (int k = 0; k <= n; ++k) {
				dp[i][j][k][0] = dp[i][j][k][1] = 1e9 + 7;
			}
		}
	}
	dp[0][n + 1][0][0] = dp[0][n + 1][0][1] = 0;
	for (int l = 0; l <= n; ++l) {
		for (int r = n + 1; r > l + 1; --r) {
			for (int k = 0; k <= n; ++k) {
				dp[l][r][k][0] = min(dp[l][r][k][0], dp[l][r][k][1] + L - X[r] + X[l]);
				dp[l][r][k][1] = min(dp[l][r][k][1], dp[l][r][k][0] + L - X[r] + X[l]);
				//~ debug(l, r, k, dp[l][r][k][0], dp[l][r][k][1]);
				
				if (dp[l][r][k][0] + X[l + 1] - X[l] <= T[l + 1]) {
					odp = max(odp, k + 1);
					dp[l + 1][r][k + 1][0] = min(dp[l + 1][r][k + 1][0], dp[l][r][k][0] + X[l + 1] - X[l]);
				}
				else {
					dp[l + 1][r][k][0] = min(dp[l + 1][r][k][0], dp[l][r][k][0] + X[l + 1] - X[l]);
				}
				
				if (dp[l][r][k][1] + X[r] - X[r - 1] <= T[r - 1]) {
					odp = max(odp, k + 1);
					dp[l][r - 1][k + 1][1] = min(dp[l][r - 1][k + 1][1], dp[l][r][k][1] + X[r] - X[r - 1]);
				}
				else {
					dp[l][r - 1][k][1] = min(dp[l][r - 1][k][1], dp[l][r][k][1] + X[r] - X[r - 1]);
				}
			}
		}
	}
	printf("%d\n", odp);
	return 0;
}

Compilation message

ho_t3.cpp: In function 'int main()':
ho_t3.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |  scanf("%d%d", &n, &L);
      |  ~~~~~^~~~~~~~~~~~~~~~
ho_t3.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |   scanf("%d", &X[i]);
      |   ~~~~~^~~~~~~~~~~~~
ho_t3.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |   scanf("%d", &T[i]);
      |   ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 420 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 596 KB Output is correct
17 Correct 1 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 420 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 596 KB Output is correct
17 Correct 1 ms 596 KB Output is correct
18 Correct 1 ms 724 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 572 KB Output is correct
21 Correct 1 ms 700 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 1 ms 724 KB Output is correct
24 Correct 1 ms 724 KB Output is correct
25 Correct 1 ms 700 KB Output is correct
26 Correct 1 ms 724 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 1 ms 724 KB Output is correct
30 Correct 1 ms 724 KB Output is correct
31 Correct 1 ms 724 KB Output is correct
32 Correct 1 ms 724 KB Output is correct
33 Correct 1 ms 724 KB Output is correct
34 Correct 1 ms 724 KB Output is correct
35 Correct 1 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 420 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 596 KB Output is correct
17 Correct 1 ms 596 KB Output is correct
18 Correct 34 ms 54848 KB Output is correct
19 Correct 21 ms 33492 KB Output is correct
20 Correct 11 ms 18112 KB Output is correct
21 Correct 20 ms 31656 KB Output is correct
22 Correct 25 ms 40880 KB Output is correct
23 Correct 10 ms 15356 KB Output is correct
24 Correct 7 ms 12200 KB Output is correct
25 Correct 8 ms 15060 KB Output is correct
26 Correct 3 ms 5972 KB Output is correct
27 Correct 9 ms 15700 KB Output is correct
28 Correct 6 ms 11348 KB Output is correct
29 Correct 12 ms 16012 KB Output is correct
30 Correct 9 ms 12756 KB Output is correct
31 Correct 9 ms 15112 KB Output is correct
32 Correct 4 ms 8020 KB Output is correct
33 Correct 10 ms 15036 KB Output is correct
34 Correct 3 ms 5588 KB Output is correct
35 Correct 9 ms 14836 KB Output is correct
36 Correct 4 ms 7252 KB Output is correct
37 Correct 9 ms 15676 KB Output is correct
38 Correct 4 ms 8756 KB Output is correct
39 Correct 10 ms 16340 KB Output is correct
40 Correct 5 ms 9684 KB Output is correct
41 Correct 48 ms 67496 KB Output is correct
42 Correct 29 ms 45652 KB Output is correct
43 Correct 50 ms 67504 KB Output is correct
44 Correct 28 ms 45136 KB Output is correct
45 Correct 51 ms 67404 KB Output is correct
46 Correct 30 ms 45652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 420 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 596 KB Output is correct
17 Correct 1 ms 596 KB Output is correct
18 Correct 1 ms 724 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 572 KB Output is correct
21 Correct 1 ms 700 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 1 ms 724 KB Output is correct
24 Correct 1 ms 724 KB Output is correct
25 Correct 1 ms 700 KB Output is correct
26 Correct 1 ms 724 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 1 ms 724 KB Output is correct
30 Correct 1 ms 724 KB Output is correct
31 Correct 1 ms 724 KB Output is correct
32 Correct 1 ms 724 KB Output is correct
33 Correct 1 ms 724 KB Output is correct
34 Correct 1 ms 724 KB Output is correct
35 Correct 1 ms 724 KB Output is correct
36 Correct 34 ms 54848 KB Output is correct
37 Correct 21 ms 33492 KB Output is correct
38 Correct 11 ms 18112 KB Output is correct
39 Correct 20 ms 31656 KB Output is correct
40 Correct 25 ms 40880 KB Output is correct
41 Correct 10 ms 15356 KB Output is correct
42 Correct 7 ms 12200 KB Output is correct
43 Correct 8 ms 15060 KB Output is correct
44 Correct 3 ms 5972 KB Output is correct
45 Correct 9 ms 15700 KB Output is correct
46 Correct 6 ms 11348 KB Output is correct
47 Correct 12 ms 16012 KB Output is correct
48 Correct 9 ms 12756 KB Output is correct
49 Correct 9 ms 15112 KB Output is correct
50 Correct 4 ms 8020 KB Output is correct
51 Correct 10 ms 15036 KB Output is correct
52 Correct 3 ms 5588 KB Output is correct
53 Correct 9 ms 14836 KB Output is correct
54 Correct 4 ms 7252 KB Output is correct
55 Correct 9 ms 15676 KB Output is correct
56 Correct 4 ms 8756 KB Output is correct
57 Correct 10 ms 16340 KB Output is correct
58 Correct 5 ms 9684 KB Output is correct
59 Correct 48 ms 67496 KB Output is correct
60 Correct 29 ms 45652 KB Output is correct
61 Correct 50 ms 67504 KB Output is correct
62 Correct 28 ms 45136 KB Output is correct
63 Correct 51 ms 67404 KB Output is correct
64 Correct 30 ms 45652 KB Output is correct
65 Correct 40 ms 60876 KB Output is correct
66 Correct 38 ms 56016 KB Output is correct
67 Correct 39 ms 53588 KB Output is correct
68 Correct 40 ms 49592 KB Output is correct
69 Correct 50 ms 60368 KB Output is correct
70 Correct 46 ms 57868 KB Output is correct
71 Correct 37 ms 58428 KB Output is correct
72 Correct 41 ms 59068 KB Output is correct
73 Correct 34 ms 54844 KB Output is correct
74 Correct 34 ms 51292 KB Output is correct
75 Correct 40 ms 56584 KB Output is correct
76 Correct 44 ms 64776 KB Output is correct
77 Correct 41 ms 64824 KB Output is correct
78 Correct 31 ms 50144 KB Output is correct
79 Correct 35 ms 51812 KB Output is correct
80 Correct 46 ms 63560 KB Output is correct
81 Correct 37 ms 52368 KB Output is correct
82 Correct 38 ms 55380 KB Output is correct
83 Correct 46 ms 67404 KB Output is correct
84 Correct 46 ms 57804 KB Output is correct
85 Correct 43 ms 62824 KB Output is correct
86 Correct 49 ms 61552 KB Output is correct
87 Correct 39 ms 56664 KB Output is correct
88 Correct 51 ms 68044 KB Output is correct
89 Correct 45 ms 68156 KB Output is correct
90 Correct 40 ms 57292 KB Output is correct
91 Correct 52 ms 68140 KB Output is correct
92 Correct 47 ms 68160 KB Output is correct
93 Correct 45 ms 66756 KB Output is correct