#include <bits/stdc++.h>
#define N 10001
using namespace std;
typedef long long ll;
int n, k, v[N], tot, used[N], mod = 1000007;
int dp[N][N];
int solve(int i, int k)
{
if(i > n) return 1;
if(dp[i][k] != -1) return dp[i][k];
ll A = (((ll)solve(i + 1, k) * (ll)k) % mod + solve(i + 1, k + 1) % mod)%mod;
return dp[i][k] = A;
}
inline ll pos()
{
set<ll> add;
ll q;
memset(dp, -1, sizeof dp);
for(ll i = 1; i <= n; i++)
{
tot = (tot + (ll)solve(i + 1, add.size())*((ll)v[i] - 1LL) )%mod;
add.insert(v[i]);
}
return (tot + 1)%mod;
}
int main()
{
ios::sync_with_stdio(false); cin.tie(0);
cin>>n;
for(int i = 1; i <= n; i++) cin>>v[i];
cout<<pos()<<"\n";
}
Compilation message
teams.cpp: In function 'll pos()':
teams.cpp:25:5: warning: unused variable 'q' [-Wunused-variable]
ll q;
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
575 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
707 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
569 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
650 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
638 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
663 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
614 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
631 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
613 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
662 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |