Submission #910124

# Submission time Handle Problem Language Result Execution time Memory
910124 2024-01-17T23:30:52 Z OAleksa Collecting Stamps 3 (JOI20_ho_t3) C++14
0 / 100
2 ms 8540 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][N][2];
//prvih i, poslednjih j, pokupio, i/j
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++) {
  			for (int k = 0;k <= n;k++)
  				dp[i][j][k][0] = dp[i][j][k][1] = inf;
  		}
  	}
  	dp[0][0][0][0] = dp[0][0][0][1] = 0;
  	int ans = 0;
  	for (int cnt = 0;cnt <= n;cnt++) {
  		for (int i = 0;i <= n;i++) {
  			for (int j = 0;j <= n;j++) {
  				if (i > 0) {
  					dp[i][j][cnt][0] = min(dp[i][j][cnt][0], dp[i - 1][j][cnt][0] + x[i] - x[i - 1]);
  					dp[i][j][cnt][0] = min(dp[i][j][cnt][0], dp[i - 1][j][cnt][1] + x[i] + (l - x[n - j + 1]));
  					if (cnt > 0) {
  						int time1 = dp[i - 1][j][cnt - 1][0] + x[i] - x[i - 1];
  						int time2 = dp[i - 1][j][cnt - 1][1] + x[i] + (l - x[n - j + 1]);
  						int time = min(time1, time2);
  						if (time <= t[i])
  							dp[i][j][cnt][0] = min(dp[i][j][cnt][0], time);
  					}
  				}
  				if (j > 0) {
  					dp[i][j][cnt][1] = min(dp[i][j][cnt][1], dp[i][j - 1][cnt][1] + x[n - j + 2] - x[n - j + 1]);
  					dp[i][j][cnt][1] = min(dp[i][j][cnt][1], dp[i][j - 1][cnt][0] + x[i] + (l - x[n - j + 1]));
  					if (cnt > 0) {
	  					int time1 = dp[i][j - 1][cnt - 1][1] + x[n - j + 2] - x[n - j + 1];
	  					int time2 = dp[i][j - 1][cnt - 1][0] + x[i] + (l - x[n - j + 1]);
	  					int time = min(time1, time2);
	  					if (time <= t[n - j + 1])
	  						dp[i][j][cnt][1] = min(dp[i][j][cnt][1], time);
  					}
  				}
  				if (dp[i][j][cnt][0] != inf || dp[i][j][cnt][1] != inf)
  					ans = cnt;
  			}
  		}
  	}
  	cout << ans;
	}
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 2 ms 4444 KB Output is correct
3 Correct 1 ms 6488 KB Output is correct
4 Correct 1 ms 4696 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 1 ms 6488 KB Output is correct
8 Correct 2 ms 8536 KB Output is correct
9 Correct 2 ms 8540 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 2 ms 8540 KB Output is correct
13 Correct 2 ms 8540 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 1 ms 6492 KB Output is correct
16 Incorrect 2 ms 8536 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 2 ms 4444 KB Output is correct
3 Correct 1 ms 6488 KB Output is correct
4 Correct 1 ms 4696 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 1 ms 6488 KB Output is correct
8 Correct 2 ms 8536 KB Output is correct
9 Correct 2 ms 8540 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 2 ms 8540 KB Output is correct
13 Correct 2 ms 8540 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 1 ms 6492 KB Output is correct
16 Incorrect 2 ms 8536 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 2 ms 4444 KB Output is correct
3 Correct 1 ms 6488 KB Output is correct
4 Correct 1 ms 4696 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 1 ms 6488 KB Output is correct
8 Correct 2 ms 8536 KB Output is correct
9 Correct 2 ms 8540 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 2 ms 8540 KB Output is correct
13 Correct 2 ms 8540 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 1 ms 6492 KB Output is correct
16 Incorrect 2 ms 8536 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 2 ms 4444 KB Output is correct
3 Correct 1 ms 6488 KB Output is correct
4 Correct 1 ms 4696 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 1 ms 6488 KB Output is correct
8 Correct 2 ms 8536 KB Output is correct
9 Correct 2 ms 8540 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 2 ms 8540 KB Output is correct
13 Correct 2 ms 8540 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 1 ms 6492 KB Output is correct
16 Incorrect 2 ms 8536 KB Output isn't correct
17 Halted 0 ms 0 KB -