Submission #1072997

#TimeUsernameProblemLanguageResultExecution timeMemory
1072997DucNguyen2007Calvinball championship (CEOI15_teams)C++14
100 / 100
95 ms604 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define pii pair<int,int> #define pll pair<ll,ll> #define fi first #define se second const int maxN=1e4+5,MOD=1000007; const ll inf=2e18; int n,a[maxN+1],dp[maxN+1],s[maxN+1]; int main() { //freopen("","r",stdin); //freopen("","w",stdout); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n; s[0]=0; for(int i=1;i<=n;i++) { cin>>a[i]; s[i]=max(s[i-1],a[i]); } memset(dp,0,sizeof(dp)); int ans=0,mx=0; for(int i=1;i<=n;i++) { for(int j=i;j>=2;j--) { dp[j]=(1LL*dp[j]*j+dp[j-1])%MOD; } dp[mx]=(dp[mx]+a[i]-1)%MOD; mx=max(mx,a[i]); } for(int i=1;i<=n;i++) { ans=(ans+dp[i])%MOD; } cout<<(ans+1)%MOD; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...