# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
93591 | 2019-01-09T23:10:44 Z | abood101 | Calvinball championship (CEOI15_teams) | C++17 | 1000 ms | 780 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; dp1[!f][j-1]=0; dp[!f][j-1][1]=dp[!f][j-1][0]=0; } 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; dp1[!f][mx-1]=0; dp[!f][mx][1]=dp[!f][mx-1][1]=0; dp[!f][mx][0]=dp[!f][mx-1][0]=0; } for(int i=1;i<mx;i++){ an+=dp1[f][i]; if(an>mod)an-=mod; } an+=dp[f][mx][1]+1; if(an>mod)an-=mod; printf("%d\n",an); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Incorrect | 2 ms | 376 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 256 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 380 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 256 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1029 ms | 780 KB | Time limit exceeded |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 12 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 33 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |