Submission #856529

# Submission time Handle Problem Language Result Execution time Memory
856529 2023-10-03T19:01:27 Z aymanrs Calvinball championship (CEOI15_teams) C++14
0 / 100
129 ms 604 KB
#include<bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,bmi,bmi2,popcnt,lzcnt")
using namespace std;
const int M = 1e9+7;
void solve(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0;i < n;i++) {
        cin >> a[i];
        a[i]--;
        if(i) a[i]=max(a[i-1], a[i]);
    }
    long long dp[n];
    fill(dp,dp+n, 1);
    long long ans = 1;
    for(int i = n-1;i;i--){
        ans += a[i]*dp[a[i-1]];
        ans%=M;
        for(int j = 0;j < n-1;j++){
            dp[j] = ((j+1)*dp[j] + dp[j+1])%M;
        }
        dp[n-1]=0;
    }
    cout << ans%M << '\n';
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 456 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 124 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 129 ms 572 KB Output isn't correct
2 Halted 0 ms 0 KB -