Submission #593404

# Submission time Handle Problem Language Result Execution time Memory
593404 2022-07-11T05:05:55 Z Hanksburger Calvinball championship (CEOI15_teams) C++17
100 / 100
91 ms 504 KB
#include <bits/stdc++.h>
using namespace std;
const int mod=1e6+7;
int a[10005], m[10005], d[10005], p[10005];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, ans=1;
    cin >> n;
    for (int i=1; i<=n; i++)
    {
        cin >> a[i];
        m[i]=max(m[i-1], a[i]);
        d[i]=1;
    }
    for (int i=n-1; i; i--)
    {
        ans=(ans+d[m[i]]*(a[i+1]-1LL))%mod;
        for (int j=1; j<=i; j++)
            p[j]=((long long)d[j]*j+d[j+1])%mod;
        for (int j=1; j<=i; j++)
            d[j]=p[j];
    }
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 324 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 2 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 89 ms 500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 340 KB Output is correct
2 Correct 25 ms 340 KB Output is correct
3 Correct 25 ms 420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 91 ms 468 KB Output is correct
2 Correct 90 ms 484 KB Output is correct
3 Correct 91 ms 504 KB Output is correct