Submission #403654

#TimeUsernameProblemLanguageResultExecution timeMemory
403654salehCalvinball championship (CEOI15_teams)C++17
100 / 100
442 ms1092 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 10 * 1000 + 23, D = 1000 * 1000 + 7; int dp[2][MAXN], a[MAXN], n, cnt[MAXN], jav; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr), cout.tie(nullptr); cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; { set<int> s; for (int i = 0; i < n; i++) { s.insert(a[i]); cnt[i] = s.size(); } } fill(dp[1], dp[1] + n, 1); for (int i = 0; i < n - 1; i++) { for (int j = 1; j < n - 1; j++) dp[i & 1][j] = (1ll * dp[1 - (i & 1)][j] * j % D + dp[1 - (i & 1)][j + 1]) % D; int j = n - i - 1; jav += 1ll * (a[j] - 1) * dp[1 - (i & 1)][cnt[j - 1]] % D; jav %= D; } cout << (jav + 1) % D; return 0; }
#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...