Submission #67896

#TimeUsernameProblemLanguageResultExecution timeMemory
67896polyfishCalvinball championship (CEOI15_teams)C++14
70 / 100
378 ms1080 KiB
//I love armpit fetish #include <bits/stdc++.h> using namespace std; #define debug(x) cerr << #x << " = " << x << '\n'; #define BP() cerr << "OK!\n"; #define PR(A, n) {cerr << #A << " = "; for (int _=1; _<=n; ++_) cerr << A[_] << ' '; cerr << '\n';} #define PR0(A, n) {cerr << #A << " = "; for (int _=0; _<n; ++_) cerr << A[_] << ' '; cerr << '\n';} #define FILE_NAME "data" const int MAX_N = 10002; const int MOD = 1000007; int n, a[MAX_N], max_a[MAX_N], f[2][MAX_N]; void enter() { cin >> n; for (int i=1; i<=n; ++i) cin >> a[i]; } void solve() { int res = 0, cur = 0; for (int last=1; last<=n; ++last) f[cur][last] = 1; for (int i=1; i<=n; ++i) max_a[i] = max(max_a[i-1], a[i]); for (int i=n; i>=1; --i) { cur ^= 1; for (int nGroup=1; nGroup<i; ++nGroup) { f[cur][nGroup] = (f[cur^1][nGroup+1] + f[cur^1][nGroup] * nGroup) % MOD; } for (int j=1; j<a[i]; ++j) res = (res + f[cur^1][max(max_a[i-1], j)]) % MOD; } cout << res + 1; } int main() { //#define OFFLINE_JUDGE doraemon #ifdef OFFLINE_JUDGE freopen(FILE_NAME".inp", "r", stdin); freopen(FILE_NAME".out", "w", stdout); #endif ios::sync_with_stdio(0); cin.tie(0); enter(); solve(); }
#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...