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;
int n, l;
int a[12];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>l;
for(int i=0; i<n; i++) cin>>a[i];
sort(a, a+n);
int br=0;
do
{
int sum=0;
for(int i=1; i<n; i++)
{
sum+=max(a[i]-a[i-1], a[i-1]-a[i]);
}
if(sum<=l) br++;
}while(next_permutation(a, a+n));
cout<<br<<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... |