# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
82406 | 2018-10-30T12:59:47 Z | AngelKnows | Calvinball championship (CEOI15_teams) | C++14 | 156 ms | 66560 KB |
#include <bits/stdc++.h> using namespace std; #define FOR(i,n) for (int i=1;i<=n;i++) #define REP(i,a,b) for (int i=a;i<=b;i++) #define pb push_back #define fi first #define se second #define pi pair<int,int> #define mp make_pair #define sz(x) ((int)(x).size()) typedef long long ll; const int inf=0x3f3f3f3f; const ll linf=1e18; const int N=10000+1; const double eps=1e-5; const int mo=1e6+7; int n; int a[N]; int g[N][N]; int f[N][N]; int dp[N]; int pre; int tot; int ans; int main() { std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); scanf("%d",&n); FOR(i,n) scanf("%d",&a[i]); FOR(i,n) g[i][0]=1; FOR(i,n) FOR(j,n) { g[i][j]=(ll)g[i][j-1]*i%mo; } FOR(i,n) f[0][i]=f[1][i]=1; REP(i,2,n) FOR(j,n) { f[i][j]=((ll)f[i-1][j+1]%mo+(ll)j*f[i-1][j]%mo)%mo; } FOR(i,n) { pre=tot; tot=max(tot,a[i]); if (a[i]>1) { if (tot==pre) FOR(j,n-i+1) dp[i]+=(ll)(a[i]-1)*g[tot][j-1]%mo*f[n-i-j+1][tot+1]%mo,dp[i]%=mo; else { FOR(j,n-i+1) dp[i]+=(ll)(a[i]-1)*g[pre][j-1]%mo*f[n-i-j+1][tot]%mo,dp[i]%=mo; } } //cout<<dp[i]<<endl; ans+=dp[i]; ans%=mo; } ans=(ans+1)%mo; printf("%d\n",ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 380 KB | Output is correct |
3 | Correct | 2 ms | 444 KB | Output is correct |
4 | Correct | 2 ms | 484 KB | Output is correct |
5 | Correct | 2 ms | 484 KB | Output is correct |
6 | Correct | 2 ms | 484 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 672 KB | Output is correct |
2 | Correct | 2 ms | 672 KB | Output is correct |
3 | Correct | 2 ms | 672 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 736 KB | Output is correct |
2 | Correct | 2 ms | 736 KB | Output is correct |
3 | Correct | 2 ms | 740 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1504 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1504 KB | Output is correct |
2 | Correct | 3 ms | 1504 KB | Output is correct |
3 | Correct | 3 ms | 1504 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 6624 KB | Output is correct |
2 | Correct | 10 ms | 6624 KB | Output is correct |
3 | Correct | 12 ms | 6624 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 16612 KB | Output is correct |
2 | Correct | 32 ms | 16612 KB | Output is correct |
3 | Correct | 33 ms | 16612 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 117 ms | 66560 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 156 ms | 66560 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 121 ms | 66560 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |