Submission #65325

# Submission time Handle Problem Language Result Execution time Memory
65325 2018-08-07T11:31:47 Z bazsi700 Calvinball championship (CEOI15_teams) C++14
40 / 100
431 ms 852 KB
#include <bits/stdc++.h>

using namespace std;
#define MOD 1000007
#define ll long long int

ll dp[10005];
//ll dp2[10005];

void calc() {
    for(ll i = 1; i <= 10000; i++) {
        dp[i] = (dp[i+1]+dp[i]*i)%MOD;
    }
    /*for(int i = 1; i <= 10000; i++) {
        dp[i] = dp2[i];
    }*/
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> arr(n);
    vector<int> cnt(n+1,0);
    for(int i = 0; i < n; i++) {
        dp[i] = 1;
        cin >> arr[i];
        cnt[arr[i]]++;
    }
    dp[n] = 1;
    ll ans = 0;
    for(ll i = n-1; i >= 0; i--) {
        if(arr[i] > 1) {
            if(cnt[arr[i]] == 1) {
                ans+= ((arr[i]-1)*dp[arr[i]-1])%MOD;
            } else {
                ans+= ((arr[i]-1)*dp[arr[i]])%MOD;
            }
        }
        calc();
        cnt[arr[i]]--;
    }
    cout << ans%MOD+1;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 512 KB Output is correct
3 Correct 4 ms 588 KB Output is correct
4 Correct 3 ms 588 KB Output is correct
5 Correct 3 ms 588 KB Output is correct
6 Correct 3 ms 644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 664 KB Output is correct
2 Correct 4 ms 664 KB Output is correct
3 Correct 2 ms 664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 664 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 664 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 664 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 34 ms 664 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 269 ms 792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 196 ms 792 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 431 ms 852 KB Output isn't correct
2 Halted 0 ms 0 KB -