Submission #244452

# Submission time Handle Problem Language Result Execution time Memory
244452 2020-07-04T06:21:05 Z cheeheng Calvinball championship (CEOI15_teams) C++14
70 / 100
741 ms 8440 KB
#include <bits/stdc++.h>
using namespace std;

const int MOD = 1000007;

int A[1005];
int memo[1005][1005][2];

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);

    for(int i = 0; i < n; i ++){
        scanf("%d", &A[i]);
    }

    memset(memo, -1, sizeof(memo));

    printf("%d", dp(0, 0, 1));
    return 0;
}

Compilation message

teams.cpp: In function 'int main()':
teams.cpp:34:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
teams.cpp:37:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &A[i]);
         ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 8 ms 8192 KB Output is correct
2 Correct 9 ms 8192 KB Output is correct
3 Correct 8 ms 8192 KB Output is correct
4 Correct 8 ms 8192 KB Output is correct
5 Correct 8 ms 8192 KB Output is correct
6 Correct 8 ms 8192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 8192 KB Output is correct
2 Correct 8 ms 8192 KB Output is correct
3 Correct 8 ms 8192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 8192 KB Output is correct
2 Correct 8 ms 8192 KB Output is correct
3 Correct 8 ms 8192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8192 KB Output is correct
2 Correct 10 ms 8192 KB Output is correct
3 Correct 10 ms 8192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 102 ms 8440 KB Output is correct
2 Correct 100 ms 8192 KB Output is correct
3 Correct 101 ms 8320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 739 ms 8416 KB Output is correct
2 Correct 736 ms 8440 KB Output is correct
3 Correct 741 ms 8320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 5 ms 256 KB Time limit exceeded (wall clock)
# Verdict Execution time Memory Grader output
1 Execution timed out 5 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 6 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -