Submission #527280

#TimeUsernameProblemLanguageResultExecution timeMemory
527280chicken337Calvinball championship (CEOI15_teams)C++17
100 / 100
179 ms588 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int MOD = 1000007; signed main(){ int n; cin >> n; int a[n], p[n]; for(int i = 0; i < n; i ++) cin >> a[i]; p[0] = 0; for(int i = 1; i < n; i ++) p[i] = max(p[i-1], a[i-1]); int bef[n+1], cur[n+1]; for(int i = 0; i < n; i ++) bef[i] = 1; int ans = 1; for(int i = n-1; i >= 0; i --){ ans = (ans + (a[i]-1)*bef[p[i]]) % MOD; for(int k = 0; k < i; k ++) cur[k] = (k*bef[k] + bef[k+1]) % MOD; for(int k = 0; k <= n; k ++) swap(bef[k], cur[k]); } cout << ans; }
#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...