Submission #1121999

#TimeUsernameProblemLanguageResultExecution timeMemory
1121999AtabayRajabliCalvinball championship (CEOI15_teams)C++17
20 / 100
148 ms592 KiB
#include <bits/stdc++.h> #define all(v) v.begin(), v.end() #define int long long using namespace std; const int sz = 1e4 + 5, mod = 1e9 + 7; int n, a[sz], mx[sz], dp[2][sz]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for(int i = 1; i <= n; i++) { dp[0][i] = 1; cin >> a[i]; mx[i] = max(mx[i - 1], a[i]); } int ans = 1; mx[0] = 1; for(int i = n, cur = 1; i >= 1; i--, cur ^= 1) { ans = (dp[cur ^ 1][mx[i - 1]] * (a[i] - 1) % mod + ans) % mod; for(int j = 1; j <= i; j++) { dp[cur][j] = (dp[cur ^ 1][j] * j % mod + dp[cur ^ 1][j + 1]) % mod; } } cout << ans; } // 1 1 1 1 // 1 1 1 2 // 1 1 1 3 // 1 1 2 1 // 1 1 2 2 // 1 1 2 3 ***** // 1 2 1 1 // 1 2 1 2 // 1 2 1 3 // 1 2 2 1 // 1 2 2 2 // 1 2 2 3 // 1 1 1 // 1 1 2 --- // 1 2 1 // 1 2 2 // 1 2 3
#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...