# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
48437 | 2018-05-13T13:27:12 Z | IvanC | Calvinball championship (CEOI15_teams) | C++17 | 793 ms | 8844 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 1010; const ll MOD = 1000007LL; ll dp[MAXN][MAXN],tot; int N,vetor[MAXN]; ll solve(int pos,int maior){ if(dp[pos][maior] != -1) return dp[pos][maior]; if(pos == N){ return dp[pos][maior] = maior; } ll ans = 0; for(int i = 1;i<=min(maior+1,N);i++){ ans += solve(pos+1,max(i,maior)); } return dp[pos][maior] = ans % MOD; } int main(){ scanf("%d",&N); memset(dp,-1,sizeof(dp)); for(int i = 1;i<=N;i++) scanf("%d",&vetor[i]); int maior = 0; for(int pos = 1;pos<=N;pos++){ for(int i = 1;i<vetor[pos];i++){ if(pos != N) tot += solve(pos+1, min(N, maior+1) ); else tot++; } tot %= MOD; maior = max(maior,vetor[pos]); } tot++; tot %= MOD; printf("%lld\n",tot); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 8312 KB | Output is correct |
2 | Correct | 7 ms | 8312 KB | Output is correct |
3 | Correct | 8 ms | 8528 KB | Output is correct |
4 | Correct | 8 ms | 8528 KB | Output is correct |
5 | Correct | 8 ms | 8528 KB | Output is correct |
6 | Correct | 7 ms | 8544 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 8548 KB | Output is correct |
2 | Incorrect | 8 ms | 8576 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 8592 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 8596 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 8600 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 115 ms | 8604 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 793 ms | 8760 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 763 ms | 8796 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 8796 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 8844 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |