# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
44355 | iletavcioski | Calvinball championship (CEOI15_teams) | C++17 | 394 ms | 1428 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.
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const ll mod = 1000007;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie();
cout.tie();
int n;
cin>>n;
vector<int> v;
vector<ll> dp(n+1,1);
vector<ll> dpmax(n+1,0);
for(int i=0;i<n;i++)
{
ll a;
cin>>a;
v.push_back(a);
dpmax[i]=a;
if(i)
dpmax[i]=max(dpmax[i],dpmax[i-1]);
}
ll brojac=1;
ll maxi=0;
for(int i=n-1;i>=0;i--)
{
int a;
if(i==0)
a=0;
else
a=dpmax[i-1];
for(int j=1;j<v[i];j++)
{
brojac+=dp[max(a,j)];
brojac%=mod;
}
for(int j=1;j<=i;j++)
{
dp[j]=1LL*j*dp[j]+dp[j+1];
dp[j]%=mod;
}
}
cout<<brojac<<endl;
return 0;
}
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... |