답안 #98396

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
98396 2019-02-22T20:14:27 Z someone_aa Calvinball championship (CEOI15_teams) C++17
0 / 100
73 ms 66560 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 11000;
const ll mod = 1000007;
int dp[maxn][maxn];
int n, arr[maxn];
bool f[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++) {
            dp[i][j] = (j * dp[i-1][j])%mod + dp[i-1][j-1];
            dp[i][j] %= mod;
        }
    }

    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];

        if(arr[i] > maxv) {
            maxv = arr[i];
            f[i] = true;
        }
    }


    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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Runtime error 67 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Runtime error 62 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 68 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 58 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 61 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 60 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 64 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 73 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 66 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 62 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -