Submission #195606

# Submission time Handle Problem Language Result Execution time Memory
195606 2020-01-16T15:50:38 Z jovan_b Calvinball championship (CEOI15_teams) C++17
100 / 100
441 ms 600 KB
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
const int MOD = 1000007;
 
int n;
int niz[100005];
int tren[100005];
int dp[10005];
int dpp[10005];
 
int add(int a, int b){
    return (a+b)%MOD;
}
 
int mul(int a, int b){
    return ((ll)a*b)%MOD;
}
 
int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;
 
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> niz[i];
        tren[i] = max(niz[i], tren[i-1]);
    }
    for(int i=1; i<=n; i++){
        dpp[i] = 1;
    }
    int res = 0;
    for(int i=n; i>=1; i--){
        for(int j=1; j<=n; j++){
            dp[j] = add(mul(j, dpp[j]), dpp[j+1]);
        }
        res = add(res, mul(niz[i]-1, dpp[tren[i-1]]));
        //cout << i << " " << niz[i]-1 << " " << dpp[tren[i-1]] << endl;
        for(int j=1; j<=n; j++){
            dpp[j] = dp[j];
        }
    }
    cout << res+1 << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 416 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 8 ms 352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 1 ms 480 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 3 ms 372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 348 KB Output is correct
2 Correct 7 ms 376 KB Output is correct
3 Correct 6 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 415 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 107 ms 488 KB Output is correct
2 Correct 109 ms 496 KB Output is correct
3 Correct 110 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 441 ms 572 KB Output is correct
2 Correct 416 ms 576 KB Output is correct
3 Correct 419 ms 600 KB Output is correct