Submission #113016

#TimeUsernameProblemLanguageResultExecution timeMemory
113016Mahdi_JfriCalvinball championship (CEOI15_teams)C++14
100 / 100
200 ms540 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back const int maxn = 1e4 + 20; const int mod = 1e6 + 7; int dp[2][maxn] , a[maxn] , mx[maxn]; inline void mkay(int &a) { if(a >= mod) a -= mod; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; for(int i = 1; i <= n; i++) cin >> a[i] , mx[i] = max(mx[i - 1] , a[i]); for(int i = 0; i <= n; i++) dp[0][i] = 1; int res = 1; for(int i = 0; i < n; i++) { int x = (i&1); if(i) for(int j = 0; j <= n; j++) dp[x][j] = (1LL * dp[x ^ 1][j] * j + dp[x ^ 1][j + 1]) % mod; int tmp = 1LL * (a[n - i] - 1) * dp[x][mx[n - i - 1]] % mod; mkay(res += tmp); } cout << res << endl; }
#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...