#include <bits/stdc++.h>
#define int long long
#pragma GCC optimize("Ofast")
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define cmax(a, b) a = max(a, b)
#define cmin(a, b) a = min(a, b)
#define MEM(x, n) memset(x, n, sizeof(x))
#define pii pair<int, int>
#define pdd pair<double, double>
#define DB(x) cerr << #x << " " << x << endl;
#define endl "\n"
#define Koying ios::sync_wit_stdio(0), cin.tie(0)
#define lowbit(x) x &(-x)
#define F first
#define S second
const int INF = 0x3f3f3f3f3f3f3f3f;
using namespace std;
#define MAXN 205
int n, l;
pii x[MAXN];
/*void sol1() {
pii dp[1 << 15];
MEM(dp, 0);
for (int mask = 1; i < (n << 15); mask++) {
int cnt = 0;
for (int i = 0; i < n; i++) {
cnt++;
if (mask & (1 << i)) {
int tarmask = mask - (1 << i);
if (dp[tarmask].S + abs(x))
int owo;
}
}
}
}*/
pii dp[MAXN][MAXN * MAXN];
int ans = 0;
bitset<MAXN> vis;
void dfs(int i, int time, int depth) {
vis[i] = true;
//cout << i << endl;
cmax(ans, depth);
for (int e = 1; e <= n; e++) {
if (!vis[e] && time + min((x[i].S - x[e].S + l) % l, (x[e].S - x[i].S + l) % l) <= x[e].F) {
dfs(e, time + min((x[i].S - x[e].S + l) % l, (x[e].S - x[i].S + l) % l), depth + 1);
}
}
vis[i] = false;
}
void sol() {
cin >> n >> l;
for (int i = 1; i <= n; i++)
cin >> x[i].S;
for (int i = 1; i <= n; i++)
cin >> x[i].F;
/*if (n <= 15) {
sol1();
return;
}*/
sort(x, x + n);
for (int i = 1; i <= n; i++) {
dfs(i, min(x[i].S, l - x[i].S), 1);
}
cout << ans << endl;
}
signed main()
{
int t = 1;
//cin >> t;
sol();
return 0;
}
Compilation message
ho_t3.cpp: In function 'int main()':
ho_t3.cpp:78:9: warning: unused variable 't' [-Wunused-variable]
78 | int t = 1;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |