#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define ll long long
#define oo 1e9 + 9
#define pii pair<int, int>
using namespace std;
const int MOD = 1e9 + 7;
const int MAX = 1e4 + 100;
int comb[MAX][MAX];
void preCalc(){
comb[0][0] = 1;
for (int i = 1; i < MAX; i++)
{
comb[i][0] = comb[i][i] = 1;
for (int j = 1; j < i; j++)
{
comb[i][j] = comb[i - 1][j] + comb[i - 1][j - 1];
comb[i][j] %= MOD;
}
}
}
int main(){
preCalc();
int n, l; cin >> n >> l;
int arr[n];
for (int i = 0; i < n; i++)
{
cin >> arr[i];
}
int idx[n];
for (int i = 0; i < n; i++)
{
idx[i] = i;
}
int ans = 0;
do{
int d = 1;
for (int i = 0; i < n - 1; i++)
{
d += max(arr[idx[i]], arr[idx[i + 1]]);
}
if(d > l) continue;
ans += comb[l - d + n][n];
ans %= MOD;
}
while(next_permutation(idx, idx + n));
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1086 ms |
238504 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
197 ms |
238556 KB |
Output is correct |
2 |
Correct |
148 ms |
238580 KB |
Output is correct |
3 |
Correct |
204 ms |
238744 KB |
Output is correct |
4 |
Correct |
150 ms |
238580 KB |
Output is correct |
5 |
Correct |
195 ms |
238552 KB |
Output is correct |
6 |
Correct |
148 ms |
238576 KB |
Output is correct |
7 |
Correct |
193 ms |
238544 KB |
Output is correct |
8 |
Correct |
188 ms |
238492 KB |
Output is correct |
9 |
Correct |
154 ms |
238464 KB |
Output is correct |
10 |
Correct |
147 ms |
238536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1084 ms |
238520 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1086 ms |
238504 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |