답안 #44745

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
44745 2018-04-06T04:29:22 Z RayaBurong25_1 Calvinball championship (CEOI15_teams) C++17
20 / 100
116 ms 16764 KB
#include <stdio.h>
#define MOD 1000000007LL
int n;
int a[10005];
int dp[1005][2005];
int max(int a, int b)
{
    return (a > b)?a:b;
}
int main()
{
    scanf("%d", &n);
    int i, j;
    for (i = 0; i < n; i++)
        scanf("%d", &a[i]);
    for (i = 0; i <= n; i++)
    {
        for (j = 1; j <= 2*n; j++)
        {
            if (i == 0)
                dp[i][j] = 1;
            else if (j + 1 <= 2*n)
                dp[i][j] = (j*dp[i - 1][j] + dp[i - 1][j + 1])%MOD;
            // if (j <= 2*n - i)
                // printf("%d ", dp[i][j]);
        }
        // printf("\n");
    }
    int ans = 1, mx = 0;
    for (i = 0; i < n; i++)
    {
        for (j = 1; j < a[i]; j++)
            ans = (ans + dp[(n - 1) - i][max(mx, j)])%MOD;
        mx = max(mx, a[i]);
    }
    printf("%d", ans);
}

Compilation message

teams.cpp: In function 'int main()':
teams.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
teams.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a[i]);
         ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 436 KB Output is correct
4 Correct 2 ms 548 KB Output is correct
5 Correct 2 ms 552 KB Output is correct
6 Correct 2 ms 552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 2 ms 764 KB Output is correct
3 Correct 2 ms 764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 764 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 1100 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 1116 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 4604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 8600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 112 ms 16644 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 84 ms 16740 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 116 ms 16764 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -