# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
244464 | cheeheng | Calvinball championship (CEOI15_teams) | C++14 | 775 ms | 632 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000007;
int A[10005];
int dp[2][10005][2];
int prefixMax[10005];
int n;
/*
int dp(int i, int cur_max, int same_so_far){
if(i == n){
return 1;
}else if(memo[i][cur_max][same_so_far] != -1){
return memo[i][cur_max][same_so_far];
}else{
long long ans = 0;
if(same_so_far){
for(int j = 1; j <= A[i]; j ++){
ans += dp(i+1, max(cur_max, j), j == A[i]);
}
}else{
for(int j = 1; j <= cur_max+1; j ++){
ans += dp(i+1, max(cur_max, j), 0);
}
}
return memo[i][cur_max][same_so_far] = ans%MOD;
}
}*/
int main(){
scanf("%d", &n);
prefixMax[0] = 0;
for(int i = 0; i < n; i ++){
scanf("%d", &A[i]);
prefixMax[i+1] = max(prefixMax[i], A[i]);
}
for(int i = n; i >= 0; i --){
//long long prefix_sum = dp[(i+1)&1][max(cur_max, 0)][0];
for(int cur_max = 0; cur_max <= n; cur_max ++){
for(int same_so_far = 0; same_so_far < 2; same_so_far ++){
if(i == n){
dp[i&1][cur_max][same_so_far] = 1;
}else{
long long ans = 0;
if(same_so_far){
if(cur_max == prefixMax[i]){
for(int j = 1; j <= A[i]; j ++){
ans += dp[(i+1)&1][max(cur_max, j)][j == A[i]];
}
}
}else{
//prefix_sum += dp[(i+1)&1][max(cur_max, 0)][0];
ans = cur_max*dp[(i+1)&1][cur_max][0] + dp[(i+1)&1][cur_max+1][0];
/*for(int j = 1; j <= cur_max+1; j ++){
ans += dp[(i+1)&1][max(cur_max, j)][0];
}*/
}
dp[i&1][cur_max][same_so_far] = ans%MOD;
}
}
}
}
printf("%d", dp[0][0][1]);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |