Submission #910098

# Submission time Handle Problem Language Result Execution time Memory
910098 2024-01-17T22:04:38 Z OAleksa Collecting Stamps 3 (JOI20_ho_t3) C++14
15 / 100
6 ms 1624 KB
#include <bits/stdc++.h>
//ako ovaj vaso daso misli da me pobedjuje.....
using namespace std;
#define int long long
#define f first
#define s second
const int N = 210;
const int inf = 1e18;
int n, l, x[N], t[N], dp[N][N][2][2];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tt = 1;
  //cin >> tt;
  while (tt--) {
  	cin >> n >> l;
  	for (int i = 1;i <= n;i++) {
  		cin >> x[i];
  	}
  	for (int i = 1;i <= n;i++) {
  		cin >> t[i];
  	}
  	x[n + 1] = l;
  	for (int i = 0;i <= n;i++) {
  		for (int j = 0;j <= n;j++)
  			dp[i][j][0][0] = dp[i][j][1][0] = inf;
  	}
  	//3-i/j
  	//4-time/skor
  	dp[0][0][0][0] = dp[0][0][1][0] = 0;
  	int ans = 0;
  	for (int i = 0;i <= n;i++) {
  		for (int j = 0;j <= n;j++) {
  			if (i + j > n)
  				break;
  			for (int k = i - 1;k >= 0;k--) {
  				int time = dp[k][j][0][0] + abs(x[i] - x[k]);
					if (dp[i][j][0][1] < dp[k][j][0][1] + (time <= t[i])) {
						dp[i][j][0][1] = dp[k][j][0][1] + (time <= t[i]);
						dp[i][j][0][0] = time;
					}
					else if (dp[i][j][0][1] == dp[k][j][0][1] + (time <= t[i]))
						dp[i][j][0][0] = min(dp[i][j][0][0], time);
  				time = dp[k][j][1][0] + x[i] + (l - x[n - j + 1]);
					if (dp[i][j][0][1] < dp[k][j][1][1] + (time <= t[i])) {
						dp[i][j][0][1] = dp[k][j][1][1] + (time <= t[i]);
						dp[i][j][0][0] = time;
					}
					else if (dp[i][j][0][1] == dp[k][j][1][1] + (time <= t[i]))
						dp[i][j][0][0] = min(dp[i][j][0][0], time);
  			}
  			for (int k = j - 1;k >= 0;k--) {
  				int time = dp[i][k][1][0] + abs(x[n - j + 1] - x[n - k + 1]);
					if (dp[i][j][1][1] < dp[i][k][1][1] + (time <= t[n - j + 1])) {
						dp[i][j][1][1] = dp[i][k][1][1] + (time <= t[n - j + 1]);
						dp[i][j][1][0] = time;
					}
					else if (dp[i][j][1][1] == dp[i][k][1][1] + (time <= t[n - j + 1]))
						dp[i][j][1][0] = min(dp[i][j][1][0], time);
  				time = dp[i][k][0][0] + x[i] + (l - x[n - j + 1]);
					if (dp[i][j][1][1] < dp[i][k][0][1] + (time <= t[n - j + 1])) {
						dp[i][j][1][1] = dp[i][k][0][1] + (time <= t[n - j + 1]);
						dp[i][j][1][0] = time;
					}
					else if (dp[i][j][1][1] == dp[i][k][0][1] + (time <= t[n - j + 1]))
						dp[i][j][1][0] = min(dp[i][j][1][0], time);
  			}
  			if (i == 0 && j > 0)
  				dp[i][j][0][0] = 2 * (l - x[n - j + 1]);
  			if (j == 0 && i > 0)
  				dp[i][j][1][0] = 2 * x[i];
  			ans = max(ans, max(dp[i][j][0][1], dp[i][j][1][1]));
  		}
  	}
  	cout << ans;
	}
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 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 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 396 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 396 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 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 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 420 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 1 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 396 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 6 ms 1624 KB Output is correct
19 Correct 3 ms 1372 KB Output is correct
20 Correct 2 ms 1116 KB Output is correct
21 Correct 3 ms 1116 KB Output is correct
22 Correct 4 ms 1480 KB Output is correct
23 Correct 2 ms 856 KB Output is correct
24 Correct 1 ms 860 KB Output is correct
25 Correct 1 ms 860 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 1 ms 860 KB Output is correct
28 Correct 1 ms 860 KB Output is correct
29 Incorrect 1 ms 860 KB Output isn't correct
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 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 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 396 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 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 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 420 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 1 ms 600 KB Output is correct
36 Correct 6 ms 1624 KB Output is correct
37 Correct 3 ms 1372 KB Output is correct
38 Correct 2 ms 1116 KB Output is correct
39 Correct 3 ms 1116 KB Output is correct
40 Correct 4 ms 1480 KB Output is correct
41 Correct 2 ms 856 KB Output is correct
42 Correct 1 ms 860 KB Output is correct
43 Correct 1 ms 860 KB Output is correct
44 Correct 1 ms 604 KB Output is correct
45 Correct 1 ms 860 KB Output is correct
46 Correct 1 ms 860 KB Output is correct
47 Incorrect 1 ms 860 KB Output isn't correct
48 Halted 0 ms 0 KB -