Submission #527281

# Submission time Handle Problem Language Result Execution time Memory
527281 2022-02-17T05:10:27 Z Hydroxic_Acid Calvinball championship (CEOI15_teams) C++17
60 / 100
1000 ms 8308 KB
#include <iostream>
#include <cstring>
using namespace std;

int N;
int arr[10005];
int memo[1005][1005][2];

int dp(int idx, int num, int marker){
    if(idx >= N) return 0;
    if(idx == N - 1) return 1;
    if(num > N) return 0;
    if(memo[idx][num][marker] != -1) return memo[idx][num][marker];
    int summ = 0;
    for(int i = 1; i <= num + 1; i++){
        if(marker){
            if(i == arr[idx + 1]) summ += dp(idx + 1, max(num, i), 1);
            else if (i < arr[idx + 1]) summ += dp(idx + 1, num, 0);
            else break;
        }
        else if(i == num + 1) summ += dp(idx + 1, num + 1, 0);
        else summ += dp(idx + 1, num, 0);
        summ %= 1000007;
    }
    memo[idx][num][marker] = summ;
    return summ;
}

int main(){
    cin >> N;
    for(int i = 0; i < N; i++) cin >> arr[i];
    memset(memo, -1, sizeof(memo));
    cout << dp(0, 1, 1);
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8140 KB Output is correct
2 Correct 4 ms 8160 KB Output is correct
3 Correct 3 ms 8140 KB Output is correct
4 Correct 3 ms 8140 KB Output is correct
5 Correct 4 ms 8196 KB Output is correct
6 Correct 3 ms 8140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8140 KB Output is correct
2 Correct 3 ms 8168 KB Output is correct
3 Correct 5 ms 8140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8140 KB Output is correct
2 Correct 4 ms 8140 KB Output is correct
3 Correct 3 ms 8140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 8100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 8208 KB Output is correct
2 Correct 4 ms 8140 KB Output is correct
3 Correct 5 ms 8140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 138 ms 8140 KB Output is correct
2 Correct 162 ms 8140 KB Output is correct
3 Correct 133 ms 8140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1022 ms 8276 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1077 ms 8308 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1063 ms 8288 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1055 ms 8300 KB Time limit exceeded
2 Halted 0 ms 0 KB -