Submission #531356

#TimeUsernameProblemLanguageResultExecution timeMemory
531356sidonCalvinball championship (CEOI15_teams)C++17
100 / 100
218 ms632 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int M = 1e6+7; int32_t main() { int N; cin >> N; int a[N]; for(int &i : a) cin >> i, --i; int b[N] {a[0]}, res = 1; for(int i = 1; i < N; ++i) b[i] = max(b[i-1], a[i]); vector<int> cur(N+1, 1), dp(N+1); for(int i = N; i--; ) { swap(cur, dp); for(int j = 0; j <= N; ++j) cur[j] = ((j + 1 < N ? dp[j + 1] : 0LL) + j * dp[j]) % M; res += a[i] * dp[i ? b[i-1] + 1 : 0]; } cout << (res % M); }
#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...