답안 #720671

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
720671 2023-04-08T22:31:00 Z Juan Collecting Stamps 3 (JOI20_ho_t3) C++17
5 / 100
7 ms 4564 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = 2e2 + 5;

int ans = 0, L, mx=0;
bool mark[maxn][maxn][maxn][2];
int T[maxn], X[maxn];

int32_t main(){
	int n; cin >> n >> L;
	for(int i = 1; i <= n; i++) cin >> X[i];
	for(int i = 1; i <= n; i++) cin >> T[i], mx = max(mx, T[i]);

	priority_queue<tuple<int, int, int, int, int>> pq;
	pq.push({0, 0, n+1, 0, 0});
	mark[0][n+1][0][0] = true;
	while(pq.size()){
		auto[t, l, r, s, d] = pq.top();
		pq.pop();
		ans = max(ans, s);
		if(l==r-1 || t>mx) continue;

		if(d==0){
			int t1 = X[l+1]-X[l];
			int add1 = (t1+t <= T[l+1]);
			bool &m1 = mark[l+1][r][s+add1][d];

			int t2 = X[l]+(L-X[r-1]);
			int add2 = (t2+t <= T[r-1]);
			bool &m2 = mark[l][r-1][s+add2][1-d];

			if(!m1) m1=true, pq.push({t+t1, l+1, r, s+add1, d});
			if(!m2) m2=true, pq.push({t+t2, l, r-1, s+add2, 1-d});
		}
		else{
			int t1 = X[r]-X[r-1];
			int add1 = (t1+t <= T[r-1]);
			bool &m1 = mark[l][r-1][s+add1][d];

			int t2 = X[l+1]+(L-X[r]);
			int add2 = (t2+t <= T[l+1]);
			bool &m2 = mark[l+1][r][s+add2][1-d];

			if(!m1) m1=true, pq.push({t+t1, l, r-1, s+add1, d});
			if(!m2) m2=true, pq.push({t+t2, l+1, r, s+add2, 1-d});
		}
	}

	cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Incorrect 1 ms 340 KB Output isn't correct
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 7 ms 4564 KB Output is correct
19 Correct 6 ms 3156 KB Output is correct
20 Correct 3 ms 1848 KB Output is correct
21 Incorrect 4 ms 2900 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Incorrect 1 ms 340 KB Output isn't correct
20 Halted 0 ms 0 KB -