Submission #44748

# Submission time Handle Problem Language Result Execution time Memory
44748 2018-04-06T04:41:30 Z RayaBurong25_1 Calvinball championship (CEOI15_teams) C++17
100 / 100
402 ms 944 KB
#include <stdio.h>
#define MOD 1000007LL
int n;
int a[10005];
int mx[10005];
long long dp[10005];
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]);
    long long ans = 1;
    // int mx = 0;
    for (i = 0; i < n; i++)
    {
        if (i == 0)
            mx[i] = a[i];
        else
            mx[i] = max(mx[i - 1], a[i]);
    }
    for (i = 0; i < n - 1; i++)
    {
        for (j = 1; j <= n - i; j++)
        {
            if (i == 0)
                dp[j] = 1LL;
            else
                dp[j] = (1LL*j*dp[j] + dp[j + 1])%MOD;
            // if (j <= 2*n - i)
                // printf("%d ", dp[j]);
        }
        // printf("\n");
        for (j = 1; j < a[n - 1 - i]; j++)
            ans = (ans + dp[max(mx[n - 2 - i], j)])%MOD;
    }
    // for (i = n - 1; i > 0; i--)
    // {
    //     for (j = 1; j < a[i]; j++)
    //         ans = (ans + dp[max(mx[i - 1], j)])%MOD;
    //     // mx = max(mx, a[i]);
    // }
    printf("%lld", ans);
}

Compilation message

teams.cpp: In function 'int main()':
teams.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
teams.cpp:16: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 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 564 KB Output is correct
4 Correct 2 ms 580 KB Output is correct
5 Correct 2 ms 580 KB Output is correct
6 Correct 2 ms 580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 580 KB Output is correct
2 Correct 2 ms 624 KB Output is correct
3 Correct 2 ms 624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 624 KB Output is correct
2 Correct 2 ms 624 KB Output is correct
3 Correct 2 ms 624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 624 KB Output is correct
2 Correct 2 ms 624 KB Output is correct
3 Correct 2 ms 624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 624 KB Output is correct
2 Correct 3 ms 624 KB Output is correct
3 Correct 3 ms 624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 624 KB Output is correct
2 Correct 4 ms 636 KB Output is correct
3 Correct 6 ms 636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 378 ms 764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 764 KB Output is correct
2 Correct 33 ms 764 KB Output is correct
3 Correct 106 ms 780 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 131 ms 844 KB Output is correct
2 Correct 141 ms 852 KB Output is correct
3 Correct 402 ms 944 KB Output is correct