# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
47975 | 2018-05-09T09:44:58 Z | Extazy | Calvinball championship (CEOI15_teams) | C++17 | 137 ms | 1096 KB |
#include <bits/stdc++.h> #define endl '\n' using namespace std; const int N = 10007; const int MOD = (1e6) + 7; int n,a[N],pos,cnt; int dp[2][N]; int state_cnt[N],state_coef[N]; long long ans; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int i; scanf("%d", &n); for(i=1;i<=n;i++) { scanf("%d", &a[i]); } ans=1; cnt=1; for(pos=2;pos<=n;pos++) { if(a[pos]>cnt) { state_cnt[pos]=cnt; state_coef[pos]=cnt; ++cnt; } else { state_cnt[pos]=cnt; state_coef[pos]=a[pos]-1; } } for(cnt=0;cnt<=n;cnt++) { dp[(n+1)&1][cnt]=1; } for(pos=n;pos>=2;pos--) { ans+=dp[(pos+1)&1][state_cnt[pos]]*1ll*state_coef[pos]%MOD; for(cnt=1;cnt<pos;cnt++) { dp[pos&1][cnt]=(dp[(pos+1)&1][cnt+1]+dp[(pos+1)&1][cnt]*1ll*cnt)%MOD; } } ans%=MOD; printf("%lld\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 408 KB | Output is correct |
4 | Correct | 2 ms | 484 KB | Output is correct |
5 | Correct | 2 ms | 560 KB | Output is correct |
6 | Correct | 2 ms | 560 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 560 KB | Output is correct |
2 | Correct | 2 ms | 560 KB | Output is correct |
3 | Correct | 2 ms | 616 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 620 KB | Output is correct |
2 | Correct | 2 ms | 620 KB | Output is correct |
3 | Correct | 2 ms | 620 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 636 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 636 KB | Output is correct |
2 | Correct | 2 ms | 636 KB | Output is correct |
3 | Correct | 2 ms | 636 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 636 KB | Output is correct |
2 | Correct | 2 ms | 636 KB | Output is correct |
3 | Correct | 2 ms | 636 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 636 KB | Output is correct |
2 | Correct | 3 ms | 636 KB | Output is correct |
3 | Correct | 3 ms | 636 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 136 ms | 836 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 29 ms | 836 KB | Output is correct |
2 | Correct | 32 ms | 836 KB | Output is correct |
3 | Correct | 35 ms | 836 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 127 ms | 924 KB | Output is correct |
2 | Correct | 129 ms | 1008 KB | Output is correct |
3 | Correct | 137 ms | 1096 KB | Output is correct |