# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
34354 | 2017-11-10T16:35:27 Z | mohammad_kilani | Calvinball championship (CEOI15_teams) | C++14 | 1000 ms | 2172 KB |
#include <bits/stdc++.h> using namespace std; #define mod 1000007 #define oo 2000000000 const int N = 10010; int arr[N] ; int dp[2][N]; int mxl[N]; int n; int solve(int i,int mx){ if(i == n){ return 1; } if(dp[i][mx] != -1) return dp[i][mx]; dp[i][mx] = 0; for(int j=1;j<=mx+1;j++){ dp[i][mx] += solve(i+1,max(mx,j)); dp[i][mx] %= mod; } return dp[i][mx]; } int main() { //freopen("in.txt","r",stdin); scanf("%d",&n); memset(dp,-1,sizeof(dp)); for(int i=0;i<n;i++) scanf("%d",&arr[i]); for(int i=0;i<=n+2;i++) dp[(n & 1)][i] = 1; mxl[0] = 0; for(int i=1;i<n;i++) mxl[i] = max(mxl[i-1],arr[i-1]); int ans = 1 , mx = 0 ; for(int i=n-1;i>=0;i--){ int mx = mxl[i]; for(int j=1;j<arr[i];j++){ mx = max(mx,j); ans+= dp[(i+1) & 1][mx]; if(ans >= mod) ans-=mod; } int sum = 0 ; for(int j=1;j<=n+2;j++){ dp[i&1][j] = sum; for(int k=1;k<=j+1;k++){ dp[i&1][j] += dp[(i+1)&1][max(j,k)]; if(dp[i&1][j] >= mod) dp[i&1][j] -=mod; } } } cout << ans << endl; 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 | 3 ms | 2172 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 236 ms | 2172 KB | Output is correct |
2 | Correct | 233 ms | 2172 KB | Output is correct |
3 | Correct | 233 ms | 2172 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1000 ms | 2172 KB | Execution timed out |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1000 ms | 2172 KB | Execution timed out |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1000 ms | 2172 KB | Execution timed out |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1000 ms | 2172 KB | Execution timed out |
2 | Halted | 0 ms | 0 KB | - |