Submission #475238

#TimeUsernameProblemLanguageResultExecution timeMemory
475238stefantagaCalvinball championship (CEOI15_teams)C++14
100 / 100
444 ms708 KiB
#include <bits/stdc++.h> #define MOD 1000007 using namespace std; long long sum,v[100005],n,i,maxi,din[2][100005],inainte,acum,j,din2[1000005],ceau[1000005]; int main() { #ifdef HOME ifstream cin("date.in"); ofstream cout("date.out"); #endif // HOME cin>>n; for (i=1;i<=n;i++) { cin>>v[i]; } maxi=0; for (i=1;i<=n;i++) { ceau[n-i]=maxi; maxi=max(maxi,v[i]); } for (i=0;i<=n+5;i++) { din[0][i]=1; } din2[0]=1; for (i=1;i<=n;i++) { inainte=1-i%2; acum=i%2; for (j=0;j<=n+5;j++) { din[acum][j]=((j*din[inainte][j])%MOD+din[inainte][j+1])%MOD; if (j==ceau[i]) { din2[i]=din[acum][j]; } } } maxi=0; for (i=1;i<=n;i++) { sum=(sum+((v[i]-1)*din2[n-i])%MOD)%MOD; maxi=max(maxi,v[i]); } cout<<sum+1; return 0; }
#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...