#include <bits/stdc++.h>
using namespace std;
const long long maxn = 200 + 12, inf = 1e9 + 12;
int n, L, dist[maxn], t[maxn];
vector <int> pos, anses;
int get_dist(int a, int b){
if(a > b)
swap(a, b);
int x = abs(a - b);
x = min(x, L - b + a);
return x;
}
int main(){
cin >> n >> L;
// n = 10;
// L= 100;
for(int i = 0; i < n; i++){
cin >> dist[i];
// dist[i] = rand() % (L - 1) + 1;
}
for(int i = 0; i < n; i++){
// t[i] = rand() % (100);
cin >> t[i];
}
pos.clear();
for(int i = 0; i < n; i++)
pos.push_back(i);
int ans = 0;
int now = 0, nat = 0, st = 0;
for(int i: pos){
now += get_dist(dist[i], st);
st = dist[i];
if(now <= t[i])
nat += 1;
}
ans = max(ans, nat);
while(next_permutation(pos.begin(), pos.end())){
int now = 0, nat = 0, st = 0;
for(int i: pos){
now += get_dist(dist[i], st);
st = dist[i];
if(now <= t[i])
nat += 1;
}
ans = max(ans, nat);
}
cout << ans << 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 |
10 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Execution timed out |
2077 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 |
10 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Execution timed out |
2077 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 |
10 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Execution timed out |
2077 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 |
10 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Execution timed out |
2077 ms |
212 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |