Submission #281261

#TimeUsernameProblemLanguageResultExecution timeMemory
281261AQTCalvinball championship (CEOI15_teams)C++14
100 / 100
306 ms608 KiB
#include <bits/stdc++.h> using namespace std; int N; int arr[10005]; long long dp[10005]; const int MOD = 1000007; int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N; for(int i = 1; i<=N; i++){ cin >> arr[i]; dp[i] = 1; } long long ans = 0; for(int i = N; i; i--){ long long m = *max_element(arr, arr+i); ans += min(1LL*arr[i]-1, m) * dp[m]; for(int j = 1; j<N; j++){ dp[j] = 1LL * j * dp[j] + dp[j+1]; dp[j] %= MOD; } ans %= MOD; } cout << (ans+1)%MOD; }
#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...