답안 #957262

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
957262 2024-04-03T10:39:00 Z aaron_dcoder Collecting Stamps 3 (JOI20_ho_t3) C++17
100 / 100
81 ms 129784 KB
#define NDEBUG


#ifdef NDEBUG
#define dbg(TXTMSG) if constexpr (false) cerr << "lol"
#define dbgv(VARN) ((void)0)
#define dbgfor(COND) if constexpr (false) for (COND)

#else
#define _GLIBCXX_DEBUG 1
#define _GLIBCXX_DEBUG_PEDANTIC 1
#pragma GCC optimize("trapv")
#define dbg(TXTMSG) cerr << "\n" << TXTMSG
#define dbgv(VARN) cerr << "\n" << #VARN << " = "<< VARN << ", line " << __LINE__ << "\n"
#define dbgfor(COND) for (COND)

#endif

#include <bits/stdc++.h>
using namespace std;
using ll = long long; 
using pll = pair<ll,ll>;
#define e0 first
#define e1 second
constexpr ll INFTY = 1e18;

int main()
{
	ll N,L;
	cin >> N >> L;

	vector<ll> X(N+2);
	vector<ll> T(N+2);
	X[0] = 0;
	X[N+1] = L;
	for (ll i = 0; i < N; ++i)
	{
		cin >> X[i+1];
	}
	T[0] = -1;
	T[N+1] = -1;
	for (ll i = 0; i < N; ++i)
	{
		cin >> T[i+1];
	}


	// dp[ccw limit][cw limit][num] = {time_ccw, time_cw};

	vector<vector<vector<pll>>> dp(N+1,vector<vector<pll>>(N+1,vector<pll>(N+1,{INFTY,INFTY})));

	dp[0][0][0]={0,0};
	for (ll ns=1;ns<=N; ++ns)
	{
		dp[0][0][ns] = {INFTY,INFTY};
	}

	for (ll ccw = 0; ccw <= N; ++ccw)
	{
		for (ll cw = 0; cw <= N; ++cw)
		{
			if (cw+ccw>=N) continue;
			dbgv(ccw << " " << cw);

			for (ll ns = 0; ns < N; ++ns)
			{
				//dbgv(ns);
				// cw entend
				if (dp[ccw][cw][ns].e1<INFTY)
				{
					
					bool cancollect = T[cw]>=dp[ccw][cw][ns].e1;
					//assert(!cancollect);
				
					dp[ccw][cw+1][ns+cancollect].e1 = min(dp[ccw][cw+1][ns+cancollect].e1, (X[cw+1]-X[cw]) + dp[ccw][cw][ns].e1);

					dp[ccw+1][cw][ns+cancollect].e0 = min(dp[ccw+1][cw][ns+cancollect].e0, X[cw]+(L-X[N+1-(ccw+1)]) + dp[ccw][cw][ns].e1);

				}
				//dbgv(ns);

				// ccw extend
				if (dp[ccw][cw][ns].e0 < INFTY)
				{
					bool cancollect = T[N+1-ccw]>=dp[ccw][cw][ns].e0;
						//				assert(!cancollect);


					dp[ccw+1][cw][ns+cancollect].e0 = min(dp[ccw+1][cw][ns+cancollect].e0, (X[N+1-ccw]-X[N+1-(ccw+1)])+dp[ccw][cw][ns].e0);
					//dbg('j');
					dp[ccw][cw+1][ns+cancollect].e1 = min(dp[ccw][cw+1][ns+cancollect].e1, X[cw+1]+(L-X[N+1-(ccw)]) + dp[ccw][cw][ns].e0);
				}
			}
		}
	}


	ll outp=0;
	for (ll ccw = 0; ccw <= N; ++ccw)
	{
		for (ll cw = 0; cw <= N; ++cw)
		{
			if (cw+ccw>N) continue;
			for (ll ns = 0; ns <= N; ++ns)
			{
									dbgv(ns);
					dbg( ccw << " " << cw << " ");

				if (dp[ccw][cw][ns].e1<INFTY)
				{
					bool cancollect = T[cw]>=dp[ccw][cw][ns].e1;
					outp = max(outp,ns+cancollect);
				}
				if (dp[ccw][cw][ns].e0 < INFTY)
				{
					bool cancollect = T[N+1-ccw]>=dp[ccw][cw][ns].e0;
					outp = max(outp,ns+cancollect);
				}
			}
		}
	}
	dbgv('h');
	dbgfor (pll a : dp[1][0]) cerr << a.e0 << "," << a.e1 << "\n";

	cout << outp;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 440 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 440 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 440 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 57 ms 93532 KB Output is correct
19 Correct 29 ms 44380 KB Output is correct
20 Correct 11 ms 17624 KB Output is correct
21 Correct 27 ms 40844 KB Output is correct
22 Correct 38 ms 59996 KB Output is correct
23 Correct 8 ms 13916 KB Output is correct
24 Correct 6 ms 9564 KB Output is correct
25 Correct 8 ms 13404 KB Output is correct
26 Correct 2 ms 3420 KB Output is correct
27 Correct 8 ms 14172 KB Output is correct
28 Correct 5 ms 8796 KB Output is correct
29 Correct 9 ms 14684 KB Output is correct
30 Correct 6 ms 10328 KB Output is correct
31 Correct 8 ms 13404 KB Output is correct
32 Correct 3 ms 5212 KB Output is correct
33 Correct 9 ms 13516 KB Output is correct
34 Correct 2 ms 3160 KB Output is correct
35 Correct 7 ms 12892 KB Output is correct
36 Correct 3 ms 4444 KB Output is correct
37 Correct 10 ms 14168 KB Output is correct
38 Correct 3 ms 5980 KB Output is correct
39 Correct 9 ms 15036 KB Output is correct
40 Correct 4 ms 7000 KB Output is correct
41 Correct 74 ms 127864 KB Output is correct
42 Correct 37 ms 70748 KB Output is correct
43 Correct 80 ms 127872 KB Output is correct
44 Correct 37 ms 69456 KB Output is correct
45 Correct 77 ms 127824 KB Output is correct
46 Correct 39 ms 70736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 440 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 57 ms 93532 KB Output is correct
37 Correct 29 ms 44380 KB Output is correct
38 Correct 11 ms 17624 KB Output is correct
39 Correct 27 ms 40844 KB Output is correct
40 Correct 38 ms 59996 KB Output is correct
41 Correct 8 ms 13916 KB Output is correct
42 Correct 6 ms 9564 KB Output is correct
43 Correct 8 ms 13404 KB Output is correct
44 Correct 2 ms 3420 KB Output is correct
45 Correct 8 ms 14172 KB Output is correct
46 Correct 5 ms 8796 KB Output is correct
47 Correct 9 ms 14684 KB Output is correct
48 Correct 6 ms 10328 KB Output is correct
49 Correct 8 ms 13404 KB Output is correct
50 Correct 3 ms 5212 KB Output is correct
51 Correct 9 ms 13516 KB Output is correct
52 Correct 2 ms 3160 KB Output is correct
53 Correct 7 ms 12892 KB Output is correct
54 Correct 3 ms 4444 KB Output is correct
55 Correct 10 ms 14168 KB Output is correct
56 Correct 3 ms 5980 KB Output is correct
57 Correct 9 ms 15036 KB Output is correct
58 Correct 4 ms 7000 KB Output is correct
59 Correct 74 ms 127864 KB Output is correct
60 Correct 37 ms 70748 KB Output is correct
61 Correct 80 ms 127872 KB Output is correct
62 Correct 37 ms 69456 KB Output is correct
63 Correct 77 ms 127824 KB Output is correct
64 Correct 39 ms 70736 KB Output is correct
65 Correct 68 ms 109652 KB Output is correct
66 Correct 59 ms 96592 KB Output is correct
67 Correct 56 ms 90356 KB Output is correct
68 Correct 51 ms 80220 KB Output is correct
69 Correct 65 ms 108080 KB Output is correct
70 Correct 65 ms 101420 KB Output is correct
71 Correct 64 ms 102908 KB Output is correct
72 Correct 61 ms 104496 KB Output is correct
73 Correct 57 ms 93344 KB Output is correct
74 Correct 51 ms 84328 KB Output is correct
75 Correct 59 ms 98208 KB Output is correct
76 Correct 71 ms 120292 KB Output is correct
77 Correct 79 ms 120276 KB Output is correct
78 Correct 49 ms 81508 KB Output is correct
79 Correct 61 ms 85896 KB Output is correct
80 Correct 81 ms 116560 KB Output is correct
81 Correct 56 ms 87356 KB Output is correct
82 Correct 60 ms 95056 KB Output is correct
83 Correct 79 ms 127824 KB Output is correct
84 Correct 59 ms 101200 KB Output is correct
85 Correct 67 ms 114768 KB Output is correct
86 Correct 70 ms 111516 KB Output is correct
87 Correct 60 ms 98212 KB Output is correct
88 Correct 81 ms 129784 KB Output is correct
89 Correct 78 ms 129776 KB Output is correct
90 Correct 54 ms 99628 KB Output is correct
91 Correct 75 ms 129780 KB Output is correct
92 Correct 77 ms 129584 KB Output is correct
93 Correct 64 ms 125776 KB Output is correct