Submission #54384

# Submission time Handle Problem Language Result Execution time Memory
54384 2018-07-03T09:36:47 Z Costin Andrei Oncescu(#1303) Calvinball championship (CEOI15_teams) C++11
70 / 100
1000 ms 66560 KB
#include<bits/stdc++.h>

using namespace std;

int ans, a[10009], N, *dp[10009];
const int mod = 1e6 + 7;

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &N), ans = 1;
for (int i=1; i<=N; i++)
    scanf ("%d", &a[i]);
for (int i=1; i<=N; i++)
    dp[i] = new int[i + 2] ();
for (int i=1; i<=N; i++)
    dp[N][i] = 1;
for (int i=N - 1; i>=1; i--)
    for (int j=1; j<=i; j++)
        dp[i][j] = (1LL * dp[i + 1][j] * j + dp[i + 1][j + 1]) % mod;
int mx = 0;
for (int i=1; i<=N; i++)
{
    for (int j=1; j<a[i]; j++)
        ans = (ans + dp[i][max (mx, j)]) % mod;
    mx = max (mx, a[i]);
}
printf ("%d\n", ans);
return 0;
}

Compilation message

teams.cpp: In function 'int main()':
teams.cpp:13:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf ("%d", &N), ans = 1;
 ~~~~~~~~~~~~~~~~^~~~~~~~~
teams.cpp:15:11: 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 436 KB Output is correct
4 Correct 2 ms 440 KB Output is correct
5 Correct 2 ms 536 KB Output is correct
6 Correct 2 ms 536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 536 KB Output is correct
2 Correct 2 ms 644 KB Output is correct
3 Correct 2 ms 644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 644 KB Output is correct
2 Correct 2 ms 840 KB Output is correct
3 Correct 2 ms 840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 840 KB Output is correct
2 Correct 2 ms 840 KB Output is correct
3 Correct 2 ms 840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1244 KB Output is correct
2 Correct 3 ms 1244 KB Output is correct
3 Correct 4 ms 1272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2728 KB Output is correct
2 Correct 5 ms 2732 KB Output is correct
3 Correct 7 ms 2736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1018 ms 66560 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Runtime error 72 ms 66560 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 891 ms 66560 KB Memory limit exceeded
2 Halted 0 ms 0 KB -