Submission #231752

# Submission time Handle Problem Language Result Execution time Memory
231752 2020-05-14T15:20:58 Z mehrdad_sohrabi Calvinball championship (CEOI15_teams) C++14
10 / 100
1000 ms 768 KB
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < ll , ll >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
const int N=2e4+100,mod=1e9+7;
ll a[N];
ll dp[N];
ll ma[N];
int32_t main(){
    sync;
    ll n;
    cin >> n ;
    for (int i=1;i<=n;i++){
        cin >> a[i];
        ma[i]=max(ma[i-1],a[i]);
    }
    for (int i=0;i<N;i++) dp[i]=i+1;
    ll ans=a[n];
    for (int i=n-1;i>1;i--){
        ll z=ma[i-1];
        ans+=dp[z]*(a[i]-1)%mod;
        ans%=mod;
        for (int j=1;j<N;j++){
            dp[i]=i*dp[i]%mod+dp[i+1];
            dp[i]%=mod;
        }
    }
    cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Incorrect 6 ms 640 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 512 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 548 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 104 ms 552 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 203 ms 636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 640 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1010 ms 652 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1083 ms 768 KB Time limit exceeded
2 Halted 0 ms 0 KB -