답안 #378263

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
378263 2021-03-16T10:57:50 Z peijar Collecting Stamps 3 (JOI20_ho_t3) C++17
100 / 100
153 ms 127724 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int INF = 1e18;
const int MAXN = 201;

int minTime[MAXN][MAXN][MAXN][2];

signed main(void)
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	for (int nbPref = 0; nbPref < MAXN; ++nbPref) 
		for (int nbSuff = 0; nbSuff < MAXN; ++nbSuff) 
			for (int nbPris = 0; nbPris < MAXN; ++nbPris) 
				for (int pos = 0; pos < 2; ++pos) 
					minTime[nbPref][nbSuff][nbPris][pos] = INF;

	int nbStamps, longueur;
	cin >> nbStamps >> longueur;
	vector<int> positions(nbStamps);
	vector<int> tempsMax(nbStamps);
	for (auto &v : positions)
		cin >> v;
	for (auto &v : tempsMax)
		cin >> v;
	positions.insert(positions.begin(), 0);
	tempsMax.insert(tempsMax.begin(), INF);
	minTime[0][0][0][0] = 0;
	int sol = 0;
	for (int nbPref = 0; nbPref <= nbStamps; ++nbPref) 
		for (int nbSuff = 0; nbSuff <= nbStamps; ++nbSuff) 
			for (int nbPris = 0; nbPris <= nbStamps; ++nbPris) 
				for (int iPos(0); iPos < 2; ++iPos)
					if (minTime[nbPref][nbSuff][nbPris][iPos] < INF)
					{
						sol = max(sol, nbPris);
						int temps = minTime[nbPref][nbSuff][nbPris][iPos];
						//cout << nbPref << ' ' << nbSuff << ' ' << nbPris << ' ' << iPos << ' ' << temps << endl;
						if (nbPref + 1 + nbSuff > nbStamps) continue;
						if (!iPos)
						{
								int nxtTemps = temps + positions[nbPref+1] - positions[nbPref];
								int nxtPris = nbPris + (nxtTemps <= tempsMax[nbPref+1]);
								minTime[nbPref+1][nbSuff][nxtPris][0] =
									min(minTime[nbPref+1][nbSuff][nxtPris][0], nxtTemps);
								nxtTemps = temps + positions[nbPref] + (longueur - positions[nbStamps - nbSuff]);
								nxtPris = nbPris + (nxtTemps <= tempsMax[nbStamps-nbSuff]);
								minTime[nbPref][nbSuff+1][nxtPris][1] = 
									min(minTime[nbPref][nbSuff+1][nxtPris][1], nxtTemps);
						}
						else if (nbSuff)
						{
							int nxtTemps = temps + positions[nbStamps-nbSuff+1]
								- positions[nbStamps-nbSuff];
							int nxtPris = nbPris + (nxtTemps <= tempsMax[nbStamps-nbSuff]);
							minTime[nbPref][nbSuff+1][nxtPris][1] = 
								min(minTime[nbPref][nbSuff+1][nxtPris][1], nxtTemps);
							nxtTemps = temps + (longueur - positions[nbStamps-nbSuff+1])
								+ positions[nbPref+1];
							nxtPris = nbPris + (nxtTemps <= tempsMax[nbPref+1]);
							minTime[nbPref+1][nbSuff][nxtPris][0] = 
								min(minTime[nbPref+1][nbSuff][nxtPris][0], nxtTemps);
						}
					}
	cout << sol << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 69 ms 127468 KB Output is correct
2 Correct 72 ms 127468 KB Output is correct
3 Correct 76 ms 127468 KB Output is correct
4 Correct 69 ms 127468 KB Output is correct
5 Correct 73 ms 127468 KB Output is correct
6 Correct 68 ms 127468 KB Output is correct
7 Correct 67 ms 127468 KB Output is correct
8 Correct 69 ms 127596 KB Output is correct
9 Correct 74 ms 127468 KB Output is correct
10 Correct 68 ms 127468 KB Output is correct
11 Correct 67 ms 127468 KB Output is correct
12 Correct 68 ms 127472 KB Output is correct
13 Correct 70 ms 127468 KB Output is correct
14 Correct 70 ms 127468 KB Output is correct
15 Correct 69 ms 127468 KB Output is correct
16 Correct 67 ms 127468 KB Output is correct
17 Correct 69 ms 127468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 69 ms 127468 KB Output is correct
2 Correct 72 ms 127468 KB Output is correct
3 Correct 76 ms 127468 KB Output is correct
4 Correct 69 ms 127468 KB Output is correct
5 Correct 73 ms 127468 KB Output is correct
6 Correct 68 ms 127468 KB Output is correct
7 Correct 67 ms 127468 KB Output is correct
8 Correct 69 ms 127596 KB Output is correct
9 Correct 74 ms 127468 KB Output is correct
10 Correct 68 ms 127468 KB Output is correct
11 Correct 67 ms 127468 KB Output is correct
12 Correct 68 ms 127472 KB Output is correct
13 Correct 70 ms 127468 KB Output is correct
14 Correct 70 ms 127468 KB Output is correct
15 Correct 69 ms 127468 KB Output is correct
16 Correct 67 ms 127468 KB Output is correct
17 Correct 69 ms 127468 KB Output is correct
18 Correct 74 ms 127596 KB Output is correct
19 Correct 68 ms 127468 KB Output is correct
20 Correct 68 ms 127468 KB Output is correct
21 Correct 67 ms 127468 KB Output is correct
22 Correct 73 ms 127468 KB Output is correct
23 Correct 70 ms 127468 KB Output is correct
24 Correct 79 ms 127468 KB Output is correct
25 Correct 68 ms 127468 KB Output is correct
26 Correct 68 ms 127468 KB Output is correct
27 Correct 70 ms 127596 KB Output is correct
28 Correct 70 ms 127468 KB Output is correct
29 Correct 71 ms 127468 KB Output is correct
30 Correct 70 ms 127596 KB Output is correct
31 Correct 79 ms 127468 KB Output is correct
32 Correct 68 ms 127468 KB Output is correct
33 Correct 67 ms 127468 KB Output is correct
34 Correct 69 ms 127468 KB Output is correct
35 Correct 69 ms 127468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 69 ms 127468 KB Output is correct
2 Correct 72 ms 127468 KB Output is correct
3 Correct 76 ms 127468 KB Output is correct
4 Correct 69 ms 127468 KB Output is correct
5 Correct 73 ms 127468 KB Output is correct
6 Correct 68 ms 127468 KB Output is correct
7 Correct 67 ms 127468 KB Output is correct
8 Correct 69 ms 127596 KB Output is correct
9 Correct 74 ms 127468 KB Output is correct
10 Correct 68 ms 127468 KB Output is correct
11 Correct 67 ms 127468 KB Output is correct
12 Correct 68 ms 127472 KB Output is correct
13 Correct 70 ms 127468 KB Output is correct
14 Correct 70 ms 127468 KB Output is correct
15 Correct 69 ms 127468 KB Output is correct
16 Correct 67 ms 127468 KB Output is correct
17 Correct 69 ms 127468 KB Output is correct
18 Correct 121 ms 127468 KB Output is correct
19 Correct 96 ms 127596 KB Output is correct
20 Correct 81 ms 127596 KB Output is correct
21 Correct 91 ms 127468 KB Output is correct
22 Correct 104 ms 127468 KB Output is correct
23 Correct 92 ms 127616 KB Output is correct
24 Correct 75 ms 127468 KB Output is correct
25 Correct 79 ms 127468 KB Output is correct
26 Correct 70 ms 127468 KB Output is correct
27 Correct 78 ms 127416 KB Output is correct
28 Correct 74 ms 127468 KB Output is correct
29 Correct 80 ms 127724 KB Output is correct
30 Correct 75 ms 127572 KB Output is correct
31 Correct 86 ms 127468 KB Output is correct
32 Correct 74 ms 127596 KB Output is correct
33 Correct 78 ms 127596 KB Output is correct
34 Correct 72 ms 127468 KB Output is correct
35 Correct 74 ms 127468 KB Output is correct
36 Correct 72 ms 127456 KB Output is correct
37 Correct 79 ms 127596 KB Output is correct
38 Correct 71 ms 127468 KB Output is correct
39 Correct 75 ms 127468 KB Output is correct
40 Correct 73 ms 127468 KB Output is correct
41 Correct 143 ms 127596 KB Output is correct
42 Correct 98 ms 127468 KB Output is correct
43 Correct 153 ms 127596 KB Output is correct
44 Correct 92 ms 127468 KB Output is correct
45 Correct 141 ms 127468 KB Output is correct
46 Correct 91 ms 127596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 69 ms 127468 KB Output is correct
2 Correct 72 ms 127468 KB Output is correct
3 Correct 76 ms 127468 KB Output is correct
4 Correct 69 ms 127468 KB Output is correct
5 Correct 73 ms 127468 KB Output is correct
6 Correct 68 ms 127468 KB Output is correct
7 Correct 67 ms 127468 KB Output is correct
8 Correct 69 ms 127596 KB Output is correct
9 Correct 74 ms 127468 KB Output is correct
10 Correct 68 ms 127468 KB Output is correct
11 Correct 67 ms 127468 KB Output is correct
12 Correct 68 ms 127472 KB Output is correct
13 Correct 70 ms 127468 KB Output is correct
14 Correct 70 ms 127468 KB Output is correct
15 Correct 69 ms 127468 KB Output is correct
16 Correct 67 ms 127468 KB Output is correct
17 Correct 69 ms 127468 KB Output is correct
18 Correct 74 ms 127596 KB Output is correct
19 Correct 68 ms 127468 KB Output is correct
20 Correct 68 ms 127468 KB Output is correct
21 Correct 67 ms 127468 KB Output is correct
22 Correct 73 ms 127468 KB Output is correct
23 Correct 70 ms 127468 KB Output is correct
24 Correct 79 ms 127468 KB Output is correct
25 Correct 68 ms 127468 KB Output is correct
26 Correct 68 ms 127468 KB Output is correct
27 Correct 70 ms 127596 KB Output is correct
28 Correct 70 ms 127468 KB Output is correct
29 Correct 71 ms 127468 KB Output is correct
30 Correct 70 ms 127596 KB Output is correct
31 Correct 79 ms 127468 KB Output is correct
32 Correct 68 ms 127468 KB Output is correct
33 Correct 67 ms 127468 KB Output is correct
34 Correct 69 ms 127468 KB Output is correct
35 Correct 69 ms 127468 KB Output is correct
36 Correct 121 ms 127468 KB Output is correct
37 Correct 96 ms 127596 KB Output is correct
38 Correct 81 ms 127596 KB Output is correct
39 Correct 91 ms 127468 KB Output is correct
40 Correct 104 ms 127468 KB Output is correct
41 Correct 92 ms 127616 KB Output is correct
42 Correct 75 ms 127468 KB Output is correct
43 Correct 79 ms 127468 KB Output is correct
44 Correct 70 ms 127468 KB Output is correct
45 Correct 78 ms 127416 KB Output is correct
46 Correct 74 ms 127468 KB Output is correct
47 Correct 80 ms 127724 KB Output is correct
48 Correct 75 ms 127572 KB Output is correct
49 Correct 86 ms 127468 KB Output is correct
50 Correct 74 ms 127596 KB Output is correct
51 Correct 78 ms 127596 KB Output is correct
52 Correct 72 ms 127468 KB Output is correct
53 Correct 74 ms 127468 KB Output is correct
54 Correct 72 ms 127456 KB Output is correct
55 Correct 79 ms 127596 KB Output is correct
56 Correct 71 ms 127468 KB Output is correct
57 Correct 75 ms 127468 KB Output is correct
58 Correct 73 ms 127468 KB Output is correct
59 Correct 143 ms 127596 KB Output is correct
60 Correct 98 ms 127468 KB Output is correct
61 Correct 153 ms 127596 KB Output is correct
62 Correct 92 ms 127468 KB Output is correct
63 Correct 141 ms 127468 KB Output is correct
64 Correct 91 ms 127596 KB Output is correct
65 Correct 127 ms 127468 KB Output is correct
66 Correct 123 ms 127468 KB Output is correct
67 Correct 120 ms 127724 KB Output is correct
68 Correct 112 ms 127468 KB Output is correct
69 Correct 128 ms 127468 KB Output is correct
70 Correct 130 ms 127468 KB Output is correct
71 Correct 122 ms 127468 KB Output is correct
72 Correct 141 ms 127596 KB Output is correct
73 Correct 111 ms 127468 KB Output is correct
74 Correct 120 ms 127468 KB Output is correct
75 Correct 119 ms 127468 KB Output is correct
76 Correct 139 ms 127468 KB Output is correct
77 Correct 132 ms 127468 KB Output is correct
78 Correct 115 ms 127468 KB Output is correct
79 Correct 116 ms 127468 KB Output is correct
80 Correct 137 ms 127468 KB Output is correct
81 Correct 119 ms 127468 KB Output is correct
82 Correct 112 ms 127536 KB Output is correct
83 Correct 136 ms 127468 KB Output is correct
84 Correct 116 ms 127596 KB Output is correct
85 Correct 121 ms 127596 KB Output is correct
86 Correct 120 ms 127468 KB Output is correct
87 Correct 129 ms 127596 KB Output is correct
88 Correct 148 ms 127596 KB Output is correct
89 Correct 142 ms 127468 KB Output is correct
90 Correct 101 ms 127536 KB Output is correct
91 Correct 148 ms 127596 KB Output is correct
92 Correct 143 ms 127468 KB Output is correct
93 Correct 109 ms 127468 KB Output is correct