Submission #110617

#TimeUsernameProblemLanguageResultExecution timeMemory
110617someone_aaCalvinball championship (CEOI15_teams)C++17
70 / 100
38 ms9976 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back #define mp make_pair using namespace std; const int maxn = 1100; const ll mod = 1000007; int dp[maxn][maxn]; int a[maxn], n; bool important[maxn]; int main() { // dp[i][j] -> If we are given a sequence of arbitrary length and maximum element j, // on how many ways can we extend it if we can add exactly i elements cin>>n; for(int i=1;i<=n;i++) { dp[0][i] = 1; } for(int i=1;i<=n;i++) { //cout<<i<<": \n"; for(int j=1;j<=n;j++) { dp[i][j] = j*dp[i-1][j] + dp[i-1][j+1]; dp[i][j] %= mod; //cout<<j<<": "<<dp[i][j]<<"\n"; } } int result = 0; int maxv = 1; for(int i=1;i<=n;i++) { cin>>a[i]; result += (a[i]-1)*(dp[n-i][maxv]); result %= mod; maxv = max(maxv, a[i]); } cout<<(result+1)%mod; 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...