Submission #207668

# Submission time Handle Problem Language Result Execution time Memory
207668 2020-03-08T13:12:38 Z alexandra_udristoiu Calvinball championship (CEOI15_teams) C++14
100 / 100
347 ms 608 KB
#include<iostream>
#define mod 1000007
using namespace std;
int n, t, i, j, k;
int d[2][10005], v[10005], maxim[10005];
int main(){
    cin>> n;
    for(i = 1; i <= n; i++){
        cin>> v[i];
        maxim[i] = max(maxim[i - 1], v[i]);
    }
    for(i = 1; i <= n; i++){
        d[0][i] = 1;
    }
    t = 1;
    for(i = n; i >= 2; i--){
        for(j = 1; j < i; j++){
            d[t][j] = d[1 - t][j + 1];
            d[t][j] = (d[t][j] + j * 1LL * d[1 - t][j]) % mod;
        }
        for(j = 1; j < v[i]; j++){
            k = (k + d[1 - t][ maxim[i - 1] ]) % mod;
        }
        t = 1 - t;
    }
    k = (1 + k) % mod;
    cout<< k;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 6 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 380 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 380 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 6 ms 380 KB Output is correct
3 Correct 9 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 346 ms 608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 380 KB Output is correct
2 Correct 39 ms 376 KB Output is correct
3 Correct 93 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 141 ms 552 KB Output is correct
2 Correct 133 ms 504 KB Output is correct
3 Correct 347 ms 504 KB Output is correct