# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
43835 | 2018-03-24T16:18:59 Z | PowerOfNinjaGo | Calvinball championship (CEOI15_teams) | C++14 | 520 ms | 1096 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[2][maxn]; int k[maxn]; int main() { //#ifndef atom freopen(".in", "r", stdin); freopen(".out", "w", stdout); #endif int n; scanf("%d", &n); //while(1) { for(int i = 1; i<= n; i++) scanf("%d", &arr[i]); for(int i = 1; i<= n; i++) k[i] = max(k[i-1], arr[i-1]); for(int i = 1; i<= n+1; i++) dp[(n+1)%2][i] = 1; int ans = 0; for(int i = n; i>= 1; i--) { int f = i%2; for(int j = 0; j<= i; j++) { dp[f][j] = dp[1-f][j+1]; add(dp[f][j], mul(j, dp[1-f][j])); //printf("dp[%d][%d] = %d\n", i, j, dp[f][j]); } if(k[i]< arr[i]) { add(ans, mul(k[i], dp[1-f][k[i]])); //printf("ans is now %d\n", ans); } else { add(ans, mul(arr[i]-1, dp[1-f][k[i]])); } } printf("%d\n", ans+1); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 352 KB | Output is correct |
3 | Correct | 2 ms | 404 KB | Output is correct |
4 | Correct | 2 ms | 528 KB | Output is correct |
5 | Correct | 1 ms | 528 KB | Output is correct |
6 | Correct | 1 ms | 604 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 604 KB | Output is correct |
2 | Correct | 2 ms | 604 KB | Output is correct |
3 | Correct | 2 ms | 604 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 604 KB | Output is correct |
2 | Correct | 1 ms | 604 KB | Output is correct |
3 | Correct | 1 ms | 628 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 652 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 696 KB | Output is correct |
2 | Correct | 2 ms | 696 KB | Output is correct |
3 | Correct | 1 ms | 700 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 704 KB | Output is correct |
2 | Correct | 3 ms | 704 KB | Output is correct |
3 | Correct | 3 ms | 708 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 712 KB | Output is correct |
2 | Correct | 7 ms | 712 KB | Output is correct |
3 | Correct | 7 ms | 716 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 501 ms | 888 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 125 ms | 888 KB | Output is correct |
2 | Correct | 129 ms | 888 KB | Output is correct |
3 | Correct | 131 ms | 888 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 512 ms | 1064 KB | Output is correct |
2 | Correct | 520 ms | 1064 KB | Output is correct |
3 | Correct | 516 ms | 1096 KB | Output is correct |