This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const long long MAXN = 205;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
long long n, l, a[MAXN], t[MAXN];
void read()
{
cin >> n >> l;
for (long long i = 1; i <= n; ++ i)
cin >> a[i];
for (long long i = 1; i <= n; ++ i)
cin >> t[i];
}
long long p[MAXN], used[MAXN], ans = 0;
void check()
{
long long ttime = 0, on = 0, cnt = 0;
for (long long i = 1; i <= n; ++ i)
{
long long go = a[p[i]];
ttime += min(go - on, l - go + on);
if(ttime <= t[p[i]])cnt ++;
}
ans = max(ans, cnt);
}
void gen(long long pos)
{
if(pos > n)
{
check();
return;
}
for (long long i = 1; i <= n; ++ i)
{
if(!used[i])
{
used[i] = 1;
p[pos] = i;
gen(pos+1);
used[i] = 0;
}
}
}
int main()
{
speed();
read();
gen(1);
cout << ans << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |