Submission #781100

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