# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
34387 | 2017-11-10T20:45:51 Z | bnahmad15 | Calvinball championship (CEOI15_teams) | C++14 | 459 ms | 2172 KB |
#include <bits/stdc++.h> using namespace std; const int N = 10010,MOD = 1000007; int n,ar[N],dp[2][N],mx[N],ans = 0; int main() { scanf("%d",&n); mx[0]=0; for(int i =0 ;i<n;i++){ scanf("%d",&ar[i]); if (i){ mx[i]=max(mx[i-1],ar[i-1]); } } for (int i = 0 ;i <= n+2 ; i++) dp[n&1][i]=1; for (int i = n-1;i >= 0 ;i--){ int m = mx[i]; for (int j =1 ;j < ar[i];j++){ m = max(m,j); ans += dp[(i+1) & 1][m]; ans %= MOD; } for (int j = 1; j<=i+1;j++){ dp[i&1][j]=dp[(i+1)&1][j]*j % MOD; dp[i&1][j] += dp[(i+1)&1][j+1]; dp[i&1][j]%= MOD; } } cout<<++ans; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2172 KB | Output is correct |
2 | Correct | 0 ms | 2172 KB | Output is correct |
3 | Correct | 0 ms | 2172 KB | Output is correct |
4 | Correct | 0 ms | 2172 KB | Output is correct |
5 | Correct | 0 ms | 2172 KB | Output is correct |
6 | Correct | 0 ms | 2172 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2172 KB | Output is correct |
2 | Correct | 0 ms | 2172 KB | Output is correct |
3 | Correct | 0 ms | 2172 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2172 KB | Output is correct |
2 | Correct | 0 ms | 2172 KB | Output is correct |
3 | Correct | 0 ms | 2172 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2172 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2172 KB | Output is correct |
2 | Correct | 0 ms | 2172 KB | Output is correct |
3 | Correct | 0 ms | 2172 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2172 KB | Output is correct |
2 | Correct | 0 ms | 2172 KB | Output is correct |
3 | Correct | 0 ms | 2172 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2172 KB | Output is correct |
2 | Correct | 0 ms | 2172 KB | Output is correct |
3 | Correct | 3 ms | 2172 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 459 ms | 2172 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 49 ms | 2172 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 209 ms | 2172 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |