Submission #98399

# Submission time Handle Problem Language Result Execution time Memory
98399 2019-02-22T20:24:25 Z someone_aa Calvinball championship (CEOI15_teams) C++17
10 / 100
3 ms 384 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 20;
const ll mod = 1000007;
int dp[maxn][maxn];
int n, arr[maxn];

int count_pref(int st, int maxv, int limit) {
    memset(dp, 0, sizeof(dp));
    dp[st][maxv] = 1;
    if(maxv > limit) return 0;

    for(int i=st+1;i<=n;i++) {
        for(int j=maxv;j<=limit;j++) {
            ll temp = 1LL * (j * dp[i-1][j])%mod + dp[i-1][j-1];
            temp %= mod;
            dp[i][j] = temp;
        }
    }

    ll result = 0LL;
    for(int i=1;i<=limit;i++) {
        result += dp[n][i];
        result %= mod;
    }
    return result;
}

int main() {
    cin>>n;
    int maxv = 0;
    for(int i=1;i<=n;i++) {
        cin>>arr[i];
        maxv = max(maxv, arr[i]);
    }

    int value = 1;
    ll result = 0LL;
    for(int i=2;i<=n;i++) {
        for(int j=1;j<arr[i];j++) {
            value = max(value, j);
            result += count_pref(i, value, maxv);
            result %= mod;
        }
        value = max(value, arr[i]);
    }

    cout<<(result+1)%mod<<"\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 300 KB Output isn't correct
2 Halted 0 ms 0 KB -