# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
256954 | kimbj0709 | Calvinball championship (CEOI15_teams) | C++14 | 204 ms | 760 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000007
#define maxn 10050
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int n;
int input;
cin >> n;
vector<int> vect1(n+1);
vector<int> prefix(n+1,0);
for(int i=1;i<=n;i++){
cin >> vect1[i];
prefix[i] = vect1[i];
}
for(int i=1;i<prefix.size();i++){
prefix[i] = max(prefix[i],prefix[i-1]);
}
int dp[2][maxn];
for(int i=1;i<n;i++){
dp[0][i] = 1;
}
int ans = 0;
for(int i=1;i<n;i++){
int curr = (i%2),bef = ((i-1)%2);
for(int j=1;j<=n;j++){
dp[curr][j] = j*dp[bef][j]+dp[bef][j+1];
dp[curr][j] %= mod;
}
ans += (vect1[n-i]-1)*dp[curr][prefix[n-i-1]];
ans %= mod;
}
ans += vect1[n];
ans %= mod;
cout << ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |