Submission #109273

#TimeUsernameProblemLanguageResultExecution timeMemory
109273dupreezCalvinball championship (CEOI15_teams)C++14
10 / 100
13 ms8356 KiB
#include <iostream> #include <algorithm> #include <cstring> #include <sstream> #include <map> #include <queue> #include <vector> #include <deque> #include <climits> #define scanf scanf_s #define mk make_pair #define pb push_back using namespace std; typedef long long int ll; typedef pair<ll, ll> pos; const ll MOD = 1000000007, N = 1010.; ll n, a[N], ans = 0,dp[N][N]; ll cal(ll lgt, ll knd) { return dp[lgt][knd]; } int main() { for (int i = 1; i < N; i++)dp[0][i] = 1; for (int i = 1; i < N; i++) { for (int j = 1; j < N - 1; j++)dp[i][j] = (dp[i-1][j+1]*j) % MOD; } cin >> n; for (int i = 1; i <= n; i++)cin >> a[i]; ll knd = 0; for (int i = 1; i <= n; i++) { ll v1 = (a[i] - 1) * cal(n - i, knd + 1); v1 %= MOD; ans = (ans + v1) % MOD; knd = max(knd, a[i]); } ans = (ans + 1) % MOD; cout << ans << endl; 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...