Submission #44853

# Submission time Handle Problem Language Result Execution time Memory
44853 2018-04-08T09:09:00 Z bogdan10bos Calvinball championship (CEOI15_teams) C++14
70 / 100
33 ms 8924 KB
#include <bits/stdc++.h>

using namespace std;

//#define FILE_IO

const int mod = 1e6 + 7;

int N;
int v[10005];
int dp[1005][1005];

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d", &N);
    for(int i = 1; i <= N; i++) scanf("%d", &v[i]);

    for(int i = 1; i <= N; i++) dp[1][i] = 1;
    for(int i = 2; i <= N; i++)
        for(int j = 1; j <= N; j++)
            dp[i][j] = (dp[i - 1][j] * j + dp[i - 1][j + 1]) % mod;

    int ans = 1;
    int mx = 0;
    for(int i = 1; i <= N; i++)
    {
        for(int j = 1; j < v[i]; j++)
            (ans += dp[N - i + 1][max(mx, j)]) %= mod;
        mx = max(mx, v[i]);
    }

    printf("%d\n", ans);

    return 0;
}

Compilation message

teams.cpp: In function 'int main()':
teams.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
     ~~~~~^~~~~~~~~~
teams.cpp:21:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 1; i <= N; i++) scanf("%d", &v[i]);
                                 ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 2 ms 456 KB Output is correct
3 Correct 2 ms 456 KB Output is correct
4 Correct 3 ms 480 KB Output is correct
5 Correct 2 ms 484 KB Output is correct
6 Correct 2 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 572 KB Output is correct
3 Correct 2 ms 704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 704 KB Output is correct
2 Correct 2 ms 704 KB Output is correct
3 Correct 2 ms 704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1048 KB Output is correct
2 Correct 3 ms 1052 KB Output is correct
3 Correct 3 ms 1056 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2604 KB Output is correct
2 Correct 4 ms 2608 KB Output is correct
3 Correct 4 ms 2612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4536 KB Output is correct
2 Correct 7 ms 4540 KB Output is correct
3 Correct 9 ms 4556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 33 ms 8832 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 22 ms 8884 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 32 ms 8924 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -