# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
43829 | 2018-03-24T14:36:19 Z | PowerOfNinjaGo | Calvinball championship (CEOI15_teams) | C++14 | 1 ms | 516 KB |
//Power Of Ninja Go #include <bits/stdc++.h> //#ifdef atom #else #endif using namespace std; typedef long long ll; typedef pair<int, int> ii; #define X first #define Y second #define vi vector<int> #define vii vector< ii > #define pb push_back const int md = 1e6+7; void add(int &a, int b) { a += b; if(a>= md) a -= md; } int mul(int a, int b) { return (1LL*a*b)%md; } const int maxn = 1e4+5; int arr[maxn]; int dp[maxn][maxn]; int main() { //#ifndef atom freopen(".in", "r", stdin); freopen(".out", "w", stdout); #endif int n; scanf("%d", &n); for(int i = 1; i<= n; i++) scanf("%d", &arr[i]); for(int i = 1; i<= n; i++) dp[n+1][i] = 1; for(int i = n; i>= 1; i--) { for(int j = 0; j<= i; j++) { dp[i][j] = dp[i+1][j+1]; add(dp[i][j], mul(j, dp[i+1][j])); //printf("dp[%d][%d] = %d\n", i, j, dp[i][j]); } } int ans = 0; int k = 0; for(int i = 1; i<= n; i++) { int np = i+1; if(k< arr[i]) { add(ans, mul(k, dp[np][k])); for(int j = k+1; j< arr[i]; j++) add(ans, dp[np][j]); } else { add(ans, mul(arr[i]-1, dp[np][k])); } k = max(k, arr[i]); } printf("%d\n", ans+1); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 256 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 352 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 352 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 352 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 424 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 452 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 456 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 516 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 516 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 516 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |