Submission #462446

#TimeUsernameProblemLanguageResultExecution timeMemory
462446JovanBCalvinball championship (CEOI15_teams)C++17
100 / 100
368 ms508 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; const int MOD = 1000007; int n; int niz[100005]; int tren[100005]; int dp[10005]; int dpp[10005]; int add(int a, int b){ return (a+b)%MOD; } int mul(int a, int b){ return ((ll)a*b)%MOD; } int main(){ ios_base::sync_with_stdio(false); cout.precision(10); cout<<fixed; cin >> n; for(int i=1; i<=n; i++){ cin >> niz[i]; tren[i] = max(niz[i], tren[i-1]); } for(int i=1; i<=n; i++){ dpp[i] = 1; } int res = 0; for(int i=n; i>=1; i--){ for(int j=1; j<=n; j++){ dp[j] = add(mul(j, dpp[j]), dpp[j+1]); } res = add(res, mul(niz[i]-1, dpp[tren[i-1]])); for(int j=1; j<=n; j++){ dpp[j] = dp[j]; } } cout << res+1 << "\n"; 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...