# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
93590 | 2019-01-09T23:08:17 Z | abood101 | Calvinball championship (CEOI15_teams) | C++17 | 1000 ms | 688 KB |
#include <bits/stdc++.h> using namespace std; typedef pair<int,int > pp; typedef long long ll; int const N=1e4+1,oo=1e9,M=1e6; ll const OO=1e18; double const eps=1e-6,PI=acos(-1); int mod=M+7; int n,aa[N],dp[2][N][2],dp1[2][N]; int main(){ scanf("%d",&n); int mx=0; for(int i=0;i<n;i++){ scanf("%d",&aa[i]); mx=max(mx,aa[i]); } int f=0,an=0; dp1[f][1]=1; dp[f][1][0]=1; for(int i=1,un=1;i<n;i++){ f=1-f; un=max(un,aa[i]); dp[f][un][0]=1; for(int j=1;j<=i+1&&j<mx;j++){ dp1[f][j]=(dp1[!f][j]*1LL*j+dp1[!f][j-1])%mod; dp[f][j][1]=(dp[!f][j][1]*1LL*j+dp[!f][j][0]*1LL*min(j,aa[i]-1)+dp[!f][j-1][1])%mod; } dp[f][mx][1]=(dp[!f][mx][1]*1LL*mx+dp[!f][mx][0]*1LL*min(mx,aa[i]-1)+dp[!f][mx-1][1])%mod; } for(int i=1;i<mx;i++){ an+=dp1[f][i]; an%=mod; } an+=dp[f][mx][1]+1; an%=mod; printf("%d\n",mx); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Incorrect | 2 ms | 376 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Incorrect | 2 ms | 356 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1078 ms | 688 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 12 ms | 396 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 32 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |