#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int v[105],n,l;
ll dp[105][105][1005][3];
ll calc(int i,int j,int k,int nr)
{
if (i && (j<=0 || nr>2))
return 0;
ll &ans=dp[i][j][k][nr];
if (ans!=-1)
return ans;
if (i==n)
return (j==1 && nr==2);
int aux=(v[i+1]-v[i])*(2*j-nr)+k;
if (aux>l)
return 0;
ans=(2*j-nr)*calc(i+1,j,aux,nr)%mod;
ans=(ans+(2-nr)*calc(i+1,j+1,aux,nr+1))%mod;
ans=(ans+(2-nr)*calc(i+1,j,aux,nr+1))%mod;
ans=(ans+(j+1-nr)*calc(i+1,j+1,aux,nr))%mod;
ans=(ans+(j-1)*calc(i+1,j-1,aux,nr))%mod;
return ans;
}
int main()
{
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
int i;
scanf("%d%d",&n,&l);
for(i=1;i<=n;i++)
scanf("%d",&v[i]);
sort(v+1,v+n+1);
v[0]=v[1];
memset(dp,-1,sizeof(dp));
if (n==1){
printf("1\n");
}
else
printf("%lld\n",calc(0,0,0,0));
return 0;
}
Compilation message
skyscraper.cpp: In function 'int main()':
skyscraper.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
31 | scanf("%d%d",&n,&l);
| ~~~~~^~~~~~~~~~~~~~
skyscraper.cpp:33:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
33 | scanf("%d",&v[i]);
| ~~~~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
134 ms |
260460 KB |
Output is correct |
2 |
Correct |
134 ms |
260460 KB |
Output is correct |
3 |
Correct |
149 ms |
260460 KB |
Output is correct |
4 |
Correct |
135 ms |
260460 KB |
Output is correct |
5 |
Correct |
136 ms |
260460 KB |
Output is correct |
6 |
Correct |
138 ms |
260524 KB |
Output is correct |
7 |
Correct |
138 ms |
260460 KB |
Output is correct |
8 |
Correct |
138 ms |
260480 KB |
Output is correct |
9 |
Correct |
135 ms |
260500 KB |
Output is correct |
10 |
Correct |
144 ms |
260588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
133 ms |
260460 KB |
Output is correct |
2 |
Correct |
138 ms |
260460 KB |
Output is correct |
3 |
Correct |
136 ms |
260460 KB |
Output is correct |
4 |
Correct |
135 ms |
260460 KB |
Output is correct |
5 |
Correct |
134 ms |
260588 KB |
Output is correct |
6 |
Correct |
135 ms |
260588 KB |
Output is correct |
7 |
Correct |
137 ms |
260460 KB |
Output is correct |
8 |
Correct |
135 ms |
260460 KB |
Output is correct |
9 |
Correct |
137 ms |
260460 KB |
Output is correct |
10 |
Correct |
136 ms |
260588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
134 ms |
260460 KB |
Output is correct |
2 |
Correct |
134 ms |
260460 KB |
Output is correct |
3 |
Correct |
149 ms |
260460 KB |
Output is correct |
4 |
Correct |
135 ms |
260460 KB |
Output is correct |
5 |
Correct |
136 ms |
260460 KB |
Output is correct |
6 |
Correct |
138 ms |
260524 KB |
Output is correct |
7 |
Correct |
138 ms |
260460 KB |
Output is correct |
8 |
Correct |
138 ms |
260480 KB |
Output is correct |
9 |
Correct |
135 ms |
260500 KB |
Output is correct |
10 |
Correct |
144 ms |
260588 KB |
Output is correct |
11 |
Correct |
133 ms |
260460 KB |
Output is correct |
12 |
Correct |
138 ms |
260460 KB |
Output is correct |
13 |
Correct |
136 ms |
260460 KB |
Output is correct |
14 |
Correct |
135 ms |
260460 KB |
Output is correct |
15 |
Correct |
134 ms |
260588 KB |
Output is correct |
16 |
Correct |
135 ms |
260588 KB |
Output is correct |
17 |
Correct |
137 ms |
260460 KB |
Output is correct |
18 |
Correct |
135 ms |
260460 KB |
Output is correct |
19 |
Correct |
137 ms |
260460 KB |
Output is correct |
20 |
Correct |
136 ms |
260588 KB |
Output is correct |
21 |
Correct |
138 ms |
260608 KB |
Output is correct |
22 |
Correct |
234 ms |
260652 KB |
Output is correct |
23 |
Correct |
199 ms |
260460 KB |
Output is correct |
24 |
Correct |
205 ms |
260632 KB |
Output is correct |
25 |
Correct |
203 ms |
260460 KB |
Output is correct |
26 |
Correct |
189 ms |
260460 KB |
Output is correct |
27 |
Correct |
160 ms |
260460 KB |
Output is correct |
28 |
Correct |
169 ms |
260460 KB |
Output is correct |
29 |
Correct |
213 ms |
260632 KB |
Output is correct |
30 |
Correct |
211 ms |
260460 KB |
Output is correct |