#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int v[205], te[205], p[205];
int n, len;
int dist(int a, int b){
return min(abs(v[a] - v[b]), min(v[a], v[b]) + len - max(v[a], v[b]));
if(v[a] == 0 || v[b] == 0) return max(v[a], v[b]);
}
int solve(int i, int t){
ll ans;
if(t <= te[i]) ans = 1;
else ans = 0;
int ma = 0;
for(int j = 1; j<=n; j++){
if(j == i || p[j] == 1) continue;
p[j] = 1;
ma = max(ma, solve(j, dist(j, i) + t));
p[j] = 0;
}
return ans + ma;
}
int main(){
cin >> n >> len;
for(int i = 1; i<=n; i++) cin >> v[i];
for(int i = 1; i<=n; i++) cin >> te[i];
v[0] = 0;
te[0] = -1;
cout << solve(0, 0) << endl;;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
25 ms |
296 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Execution timed out |
2067 ms |
212 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
25 ms |
296 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Execution timed out |
2067 ms |
212 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
25 ms |
296 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Execution timed out |
2067 ms |
212 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
25 ms |
296 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Execution timed out |
2067 ms |
212 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |