Submission #475234

# Submission time Handle Problem Language Result Execution time Memory
475234 2021-09-21T15:02:06 Z stefantaga Calvinball championship (CEOI15_teams) C++14
70 / 100
287 ms 65540 KB
#include <bits/stdc++.h>
#define MOD 1000007
using namespace std;
long long sum,v[10005],fact[100005],n,i,maxi,din[2][100005],inainte,acum,j;
map <pair <long long,long long > , long long > m;
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++)
    {
        m[{n-i,maxi}]=1;
        maxi=max(maxi,v[i]);
    }
    for (i=0;i<=n+5;i++)
    {
        din[0][i]=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 (m[{i,j}]==1)
            {
                m[{i,j}]=din[acum][j];
            }
        }
    }
    maxi=0;
    for (i=1;i<=n;i++)
    {
        sum=(sum+((v[i]-1)*m[{n-i,maxi}])%MOD)%MOD;
        maxi=max(maxi,v[i]);
    }
    cout<<sum+1;
    return 0;
}
# 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 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 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 332 KB Output is correct
3 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 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 972 KB Output is correct
2 Correct 3 ms 972 KB Output is correct
3 Correct 3 ms 972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 16160 KB Output is correct
2 Correct 59 ms 16112 KB Output is correct
3 Correct 64 ms 16104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 246 ms 63260 KB Output is correct
2 Correct 244 ms 63300 KB Output is correct
3 Correct 269 ms 63216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 245 ms 65540 KB Execution killed with signal 9
# Verdict Execution time Memory Grader output
1 Runtime error 245 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 287 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -