Submission #201343

# Submission time Handle Problem Language Result Execution time Memory
201343 2020-02-10T08:41:53 Z Atalasion Collecting Stamps 3 (JOI20_ho_t3) C++14
15 / 100
63 ms 72956 KB
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 200 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000000000000000;
const ll LOG = 25;

int dp[N][N][N][2];
int n, x[N], L, T[N];

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	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;
	memset(dp, 31, sizeof dp);
	dp[0][0][0][0] = dp[0][0][0][1] = 0;
	for (int i = 0; i <= n; i++){
		for (int j = 0; j <= n - i - 1; j++){
			for (int k = 0; k <= (i + j); k++){
				//cout << i << ' ' << j << ' ' << k << ' ' << dp[i][j][k][0] << ' ' << dp[i][j][k][1] << '\n';
				int ti = dp[i][j][k][0];
				if (ti + x[i + 1] - x[i] <= T[i + 1]) dp[i + 1][j][k + 1][0] = min(dp[i + 1][j][k + 1][0], ti + x[i + 1] - x[i]);
				else dp[i + 1][j][k][0] = min(dp[i + 1][j][k][0], ti + x[i + 1] - x[i]);
				//cout << ti + x[i] + L - x[n - j] << '\n';
				if (ti + x[i] + L - x[n - j] <= T[n - j]) dp[i][j + 1][k + 1][1] = min(dp[i][j + 1][k + 1][1], ti + x[i] + L - x[n - j]);
				else dp[i][j + 1][k][1] = min(dp[i][j + 1][k][1], ti + x[i] + L - x[n - j]); 
				ti = dp[i][j][k][1];
				if (ti + x[n - j + 1] - x[n - j] <= T[n - j]) dp[i][j + 1][k + 1][1] = min(dp[i][j + 1][k + 1][1], ti + x[n - j + 1] - x[n - j]);
				else dp[i][j + 1][k][1] = min(dp[i][j + 1][k][1], ti + x[n - j + 1] - x[n - j]);
				if (L - x[n - j + 1] + ti + x[i + 1] <= T[i + 1]) dp[i + 1][j][k + 1][0] = min(dp[i + 1][j][k + 1][0], L - x[n - j + 1] + ti + x[i + 1]);
				else dp[i + 1][j][k][0] = min(dp[i + 1][j][k][0], L - x[n - j + 1] + ti + x[i + 1]);
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++){
		for (int j = 0; j <= n; j++){
			if (min(dp[j][n - j][i][0], dp[j][n - j][i][1]) <= (100000000ll)) ans = i;
		}
	}
	cout << ans;











	return 0;
}

Compilation message

ho_t3.cpp:8:0: warning: ignoring #pragma GCC optimise [-Wunknown-pragmas]
 #pragma GCC optimise ("ofast")
 
ho_t3.cpp:9:0: warning: ignoring #pragma GCC optimise [-Wunknown-pragmas]
 #pragma GCC optimise("unroll-loops")
# Verdict Execution time Memory Grader output
1 Correct 45 ms 72952 KB Output is correct
2 Correct 47 ms 72824 KB Output is correct
3 Correct 44 ms 72824 KB Output is correct
4 Correct 54 ms 72824 KB Output is correct
5 Correct 43 ms 72828 KB Output is correct
6 Correct 43 ms 72824 KB Output is correct
7 Correct 45 ms 72824 KB Output is correct
8 Correct 48 ms 72956 KB Output is correct
9 Correct 44 ms 72824 KB Output is correct
10 Correct 44 ms 72824 KB Output is correct
11 Correct 44 ms 72824 KB Output is correct
12 Correct 45 ms 72828 KB Output is correct
13 Correct 46 ms 72952 KB Output is correct
14 Correct 44 ms 72824 KB Output is correct
15 Correct 49 ms 72952 KB Output is correct
16 Correct 45 ms 72824 KB Output is correct
17 Correct 45 ms 72824 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 45 ms 72952 KB Output is correct
2 Correct 47 ms 72824 KB Output is correct
3 Correct 44 ms 72824 KB Output is correct
4 Correct 54 ms 72824 KB Output is correct
5 Correct 43 ms 72828 KB Output is correct
6 Correct 43 ms 72824 KB Output is correct
7 Correct 45 ms 72824 KB Output is correct
8 Correct 48 ms 72956 KB Output is correct
9 Correct 44 ms 72824 KB Output is correct
10 Correct 44 ms 72824 KB Output is correct
11 Correct 44 ms 72824 KB Output is correct
12 Correct 45 ms 72828 KB Output is correct
13 Correct 46 ms 72952 KB Output is correct
14 Correct 44 ms 72824 KB Output is correct
15 Correct 49 ms 72952 KB Output is correct
16 Correct 45 ms 72824 KB Output is correct
17 Correct 45 ms 72824 KB Output is correct
18 Incorrect 45 ms 72824 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 45 ms 72952 KB Output is correct
2 Correct 47 ms 72824 KB Output is correct
3 Correct 44 ms 72824 KB Output is correct
4 Correct 54 ms 72824 KB Output is correct
5 Correct 43 ms 72828 KB Output is correct
6 Correct 43 ms 72824 KB Output is correct
7 Correct 45 ms 72824 KB Output is correct
8 Correct 48 ms 72956 KB Output is correct
9 Correct 44 ms 72824 KB Output is correct
10 Correct 44 ms 72824 KB Output is correct
11 Correct 44 ms 72824 KB Output is correct
12 Correct 45 ms 72828 KB Output is correct
13 Correct 46 ms 72952 KB Output is correct
14 Correct 44 ms 72824 KB Output is correct
15 Correct 49 ms 72952 KB Output is correct
16 Correct 45 ms 72824 KB Output is correct
17 Correct 45 ms 72824 KB Output is correct
18 Correct 59 ms 72824 KB Output is correct
19 Correct 54 ms 72824 KB Output is correct
20 Correct 48 ms 72848 KB Output is correct
21 Correct 53 ms 72828 KB Output is correct
22 Correct 53 ms 72776 KB Output is correct
23 Correct 48 ms 72824 KB Output is correct
24 Correct 47 ms 72824 KB Output is correct
25 Correct 47 ms 72824 KB Output is correct
26 Correct 47 ms 72828 KB Output is correct
27 Correct 48 ms 72824 KB Output is correct
28 Correct 44 ms 72824 KB Output is correct
29 Correct 47 ms 72824 KB Output is correct
30 Correct 46 ms 72824 KB Output is correct
31 Correct 47 ms 72952 KB Output is correct
32 Correct 45 ms 72788 KB Output is correct
33 Correct 48 ms 72824 KB Output is correct
34 Correct 46 ms 72824 KB Output is correct
35 Correct 49 ms 72952 KB Output is correct
36 Correct 47 ms 72760 KB Output is correct
37 Correct 48 ms 72824 KB Output is correct
38 Correct 47 ms 72824 KB Output is correct
39 Correct 48 ms 72952 KB Output is correct
40 Correct 45 ms 72824 KB Output is correct
41 Correct 61 ms 72824 KB Output is correct
42 Correct 54 ms 72824 KB Output is correct
43 Correct 62 ms 72824 KB Output is correct
44 Correct 58 ms 72952 KB Output is correct
45 Correct 63 ms 72824 KB Output is correct
46 Correct 54 ms 72824 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 45 ms 72952 KB Output is correct
2 Correct 47 ms 72824 KB Output is correct
3 Correct 44 ms 72824 KB Output is correct
4 Correct 54 ms 72824 KB Output is correct
5 Correct 43 ms 72828 KB Output is correct
6 Correct 43 ms 72824 KB Output is correct
7 Correct 45 ms 72824 KB Output is correct
8 Correct 48 ms 72956 KB Output is correct
9 Correct 44 ms 72824 KB Output is correct
10 Correct 44 ms 72824 KB Output is correct
11 Correct 44 ms 72824 KB Output is correct
12 Correct 45 ms 72828 KB Output is correct
13 Correct 46 ms 72952 KB Output is correct
14 Correct 44 ms 72824 KB Output is correct
15 Correct 49 ms 72952 KB Output is correct
16 Correct 45 ms 72824 KB Output is correct
17 Correct 45 ms 72824 KB Output is correct
18 Incorrect 45 ms 72824 KB Output isn't correct
19 Halted 0 ms 0 KB -