답안 #44746

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
44746 2018-04-06T04:30:08 Z RayaBurong25_1 Calvinball championship (CEOI15_teams) C++17
20 / 100
311 ms 32324 KB
#include <stdio.h>
#define MOD 1000000007LL
int n;
int a[10005];
long long dp[1005][2005];
long long max(long long a, long long 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] = 1LL;
            else if (j + 1 <= 2*n)
                dp[i][j] = (1LL*j*dp[i - 1][j] + dp[i - 1][j + 1])%MOD;
            // if (j <= 2*n - i)
                // printf("%d ", dp[i][j]);
        }
        // printf("\n");
    }
    long long ans = 1;
    int 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:37:21: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
     printf("%d", ans);
                     ^
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 256 KB Output is correct
2 Correct 2 ms 476 KB Output is correct
3 Correct 2 ms 476 KB Output is correct
4 Correct 2 ms 476 KB Output is correct
5 Correct 2 ms 476 KB Output is correct
6 Correct 2 ms 476 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 476 KB Output is correct
2 Correct 2 ms 680 KB Output is correct
3 Correct 2 ms 680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 680 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 1124 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 1124 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 6500 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 42 ms 16208 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 288 ms 32228 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 168 ms 32324 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 311 ms 32324 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -