Submission #154204

# Submission time Handle Problem Language Result Execution time Memory
154204 2019-09-19T00:42:18 Z arnold518 Calvinball championship (CEOI15_teams) C++14
100 / 100
263 ms 764 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e4;
const ll MOD = 1e6+7;

int N, A[MAXN+10], B[MAXN+10];
ll dp[3][MAXN+10], ans;

int main()
{
    int i, j;

    scanf("%d", &N);
    for(i=1; i<=N; i++) scanf("%d", &A[i]);
    for(i=1; i<=N; i++) B[i]=max(B[i-1], A[i]);

    for(j=1; j<=N; j++) dp[0][j]=1;
    ans+=A[N]-1;
    for(i=1; i<=N; i++)
    {
        for(j=1; j<=N; j++)
        {
            dp[i&1][j]=dp[i-1&1][j]*j+dp[i-1&1][j+1];
            dp[i&1][j]%=MOD;
        }
        for(j=1; j<A[N-i]; j++) ans+=dp[i&1][max(j, B[N-i-1])];
        ans%=MOD;
    }
    printf("%lld", ans+1);
}

Compilation message

teams.cpp: In function 'int main()':
teams.cpp:28:28: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
             dp[i&1][j]=dp[i-1&1][j]*j+dp[i-1&1][j+1];
                           ~^~
teams.cpp:28:43: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
             dp[i&1][j]=dp[i-1&1][j]*j+dp[i-1&1][j+1];
                                          ~^~
teams.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
     ~~~~~^~~~~~~~~~
teams.cpp:19:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=1; i<=N; i++) scanf("%d", &A[i]);
                         ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# 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 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 253 ms 624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 380 KB Output is correct
2 Correct 56 ms 504 KB Output is correct
3 Correct 67 ms 508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 214 ms 648 KB Output is correct
2 Correct 213 ms 628 KB Output is correct
3 Correct 263 ms 764 KB Output is correct