Submission #527195

# Submission time Handle Problem Language Result Execution time Memory
527195 2022-02-17T03:29:08 Z Hydroxic_Acid Calvinball championship (CEOI15_teams) C++17
0 / 100
39 ms 65540 KB
#include <iostream>
#include <cstring>
using namespace std;

int N;
int arr[10005];
int memo[10005][10005][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, i, 1);
            else if (i < arr[idx + 1])summ += dp(idx + 1, i, 0);
            else break;
        }
        else if(i == num + 1) summ += dp(idx + 1, num + 1, 0);
        else summ += dp(idx + 1, num, 0);
        summ %= 1000007;
    }
    return memo[idx][num][marker] = 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 Runtime error 27 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 32 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 32 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 28 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 39 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 29 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 31 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 30 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 30 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 33 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -