Submission #475238

# Submission time Handle Problem Language Result Execution time Memory
475238 2021-09-21T15:06:15 Z stefantaga Calvinball championship (CEOI15_teams) C++14
100 / 100
444 ms 708 KB
#include <bits/stdc++.h>
#define MOD 1000007
using namespace std;
long long sum,v[100005],n,i,maxi,din[2][100005],inainte,acum,j,din2[1000005],ceau[1000005];
int main()
{
    #ifdef HOME
    ifstream cin("date.in");
    ofstream cout("date.out");
    #endif // HOME
    cin>>n;
    for (i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    maxi=0;
    for (i=1;i<=n;i++)
    {
        ceau[n-i]=maxi;
        maxi=max(maxi,v[i]);
    }
    for (i=0;i<=n+5;i++)
    {
        din[0][i]=1;
    }
    din2[0]=1;
    for (i=1;i<=n;i++)
    {
        inainte=1-i%2;
        acum=i%2;
        for (j=0;j<=n+5;j++)
        {
            din[acum][j]=((j*din[inainte][j])%MOD+din[inainte][j+1])%MOD;
            if (j==ceau[i])
            {
                din2[i]=din[acum][j];
            }
        }
    }
    maxi=0;
    for (i=1;i<=n;i++)
    {
        sum=(sum+((v[i]-1)*din2[n-i])%MOD)%MOD;
        maxi=max(maxi,v[i]);
    }
    cout<<sum+1;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 352 KB Output is correct
2 Correct 5 ms 332 KB Output is correct
3 Correct 5 ms 356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 430 ms 628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 115 ms 476 KB Output is correct
2 Correct 112 ms 500 KB Output is correct
3 Correct 113 ms 500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 443 ms 636 KB Output is correct
2 Correct 438 ms 708 KB Output is correct
3 Correct 444 ms 708 KB Output is correct