Submission #68610

#TimeUsernameProblemLanguageResultExecution timeMemory
68610GoogalCalvinball championship (CEOI15_teams)C++14
100 / 100
165 ms1244 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e4 + 1; const int M = 1e6 + 7; int n, r, a[N], m[N], d[2][N]; int main() { ios::sync_with_stdio(false); cin >> n; for(int i = 1; i <= n; i++){ cin >> a[i]; m[i] = max(m[i - 1], a[i]); } fill(d[0], d[0] + N, 1); r = a[n]; for(int i = n - 1, p = 1; i >= 1; i--, p ^= 1){ for(int j = 1; j <= i; j++) d[p][j] = (d[!p][j + 1] + 1LL * j * d[!p][j]) % M; r = (r + 1LL * (a[i] - 1) * d[p][m[i - 1]]) % M; } cout << r % M << '\n'; }
#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...