Submission #117646

#TimeUsernameProblemLanguageResultExecution timeMemory
117646minhtung0404Calvinball championship (CEOI15_teams)C++17
100 / 100
217 ms640 KiB
//https://oj.uz/problem/view/CEOI15_teams #include<bits/stdc++.h> const int N = 1e4 + 5; const int mod = 1e6 + 7; using namespace std; int n, a[N], f[N], g[N], cur[N], ans; void add(int&a, int b){ a += b; if (a >= mod) a -= mod; if (a < 0) a += mod; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; cur[i] = max(cur[i-1], a[i]); } for (int i = 0; i <= n; i++) f[i] = 1; for (int i = n; i >= 1; i--){ add(ans, 1LL * f[cur[i-1]] * (a[i]-1) % mod); for (int j = 0; j <= n; j++) g[j] = (1LL * f[j] * j + f[j+1]) % mod; for (int j = 0; j <= n; j++) f[j] = g[j]; } add(ans, 1); cout << ans; }
#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...