Submission #781101

#TimeUsernameProblemLanguageResultExecution timeMemory
781101Charizard2021Calvinball championship (CEOI15_teams)C++17
100 / 100
75 ms632 KiB
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000007; int main(){ long long n; cin >> n; long long dp[2][1 + n]; long long cur = n % 2; long long a[1 + n]; long long prefMax[1 + n]; prefMax[0] = 0; for(long long i = 1; i <= n; i++){ cin >> a[i]; prefMax[i] = max(prefMax[i - 1], a[i]); dp[cur][i] = 1; } long long ans = 1; for(long long i = n - 1; i > 0; i--, cur ^= 1){ ans = (ans + dp[cur][prefMax[i]] * (a[i + 1] - 1)) % MOD; for(long long j = 1; j <= i; j++){ dp[!cur][j] = (dp[cur][j] * j + dp[cur][j + 1]) % MOD; } } cout << ans << "\n"; }
#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...