Submission #1081725

#TimeUsernameProblemLanguageResultExecution timeMemory
108172542kangarooCalvinball championship (CEOI15_teams)C++17
20 / 100
268 ms604 KiB
// // Created by 42kangaroo on 30/08/2024. // #include "bits/stdc++.h" using namespace std; using ll = long long; constexpr ll mod = 1e9 + 7; 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; } 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] * (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...