답안 #98383

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
98383 2019-02-22T19:35:14 Z someone_aa Calvinball championship (CEOI15_teams) C++17
20 / 100
99 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 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;
        }
    }

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

    ll result = 0LL;

    int j = maxv;
    for(int i=n;i>=2;i--) {
        //cout<<i<<": "<<f[i]<<" -> "<<arr[i]<<"\n";
        if(f[i]) {
            // not saving anything
            j--;
        }
        else {
            ll temp = 1LL * (arr[i]-1) * dp[i-1][j] + dp[i-1][j-1];
            //cout<<temp<<"\n";
            temp %= mod;
            result += temp;
            result %= mod;
        }
    }

    for(int i=1;i<maxv;i++) {
        result += dp[n][i];
        result %= mod;
    }

    result++;
    result %= mod;
    cout<<result<<"\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 768 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 3328 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 8320 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 97 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 96 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 99 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -