Submission #1081741

#TimeUsernameProblemLanguageResultExecution timeMemory
108174142kangarooCalvinball championship (CEOI15_teams)C++17
40 / 100
267 ms856 KiB
// // Created by 42kangaroo on 30/08/2024. // #include "bits/stdc++.h" using namespace std; using ll = long long; constexpr ll mod = 1000007; signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } vector<int> nuD(n); int act = 1; for (int i = 0; i < n; ++i) { if (a[i] > act) act++; nuD[i] = act; assert(nuD[i] >= a[i]); } vector<ll> dp(n + 1, 1), dpN(n + 1, 0); ll res = 1; for (int i = n - 1; i >= 0; --i) { res += (dp[nuD[i] - 1] * (ll)(a[i] - 1))%mod; res %= mod; for (int j = 0; j < n; ++j) { dpN[j] = (dp[j] * j)%mod + dp[j + 1]; dpN[j] %= mod; } swap(dp, dpN); } cout << res; }
#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...