Submission #25721

# Submission time Handle Problem Language Result Execution time Memory
25721 2017-06-23T19:05:24 Z gs14004 Calvinball championship (CEOI15_teams) C++11
100 / 100
376 ms 2020 KB
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long lint;
const int mod = 1000007;

int main(){
    int n, a[10005], pmax[10005];
    int d[10005];
    cin >> n;
    for(int i=0; i<n; i++) cin >> a[i], pmax[i] = max(a[i], i ? pmax[i-1] : 0);
    fill(d, d+n+1, 1);
    int ret = 1;
    for(int i=n-1; i>=0; i--){
        for(int j=1; j<a[i]; j++) ret += d[max(i ? pmax[i-1] : 0, j)], ret %= mod;
        for(int j=1; j<i; j++) d[j] = (1ll * j * d[j] + d[j+1]) % mod;
    }
    cout << ret;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 0 ms 2020 KB Output is correct
3 Correct 0 ms 2020 KB Output is correct
4 Correct 0 ms 2020 KB Output is correct
5 Correct 0 ms 2020 KB Output is correct
6 Correct 0 ms 2020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 0 ms 2020 KB Output is correct
3 Correct 0 ms 2020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 0 ms 2020 KB Output is correct
3 Correct 0 ms 2020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 0 ms 2020 KB Output is correct
3 Correct 0 ms 2020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 0 ms 2020 KB Output is correct
3 Correct 0 ms 2020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 0 ms 2020 KB Output is correct
3 Correct 3 ms 2020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 366 ms 2020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 2020 KB Output is correct
2 Correct 33 ms 2020 KB Output is correct
3 Correct 96 ms 2020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 146 ms 2020 KB Output is correct
2 Correct 169 ms 2020 KB Output is correct
3 Correct 376 ms 2020 KB Output is correct