Submission #527280

# Submission time Handle Problem Language Result Execution time Memory
527280 2022-02-17T05:09:58 Z chicken337 Calvinball championship (CEOI15_teams) C++17
100 / 100
179 ms 588 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000007;

signed main(){
    int n; cin >> n;
    int a[n], p[n];
    for(int i = 0; i < n; i ++)
        cin >> a[i];
    p[0] = 0;
    for(int i = 1; i < n; i ++)
        p[i] = max(p[i-1], a[i-1]);

    int bef[n+1], cur[n+1];
    for(int i = 0; i < n; i ++)
        bef[i] = 1;
    int ans = 1;
    for(int i = n-1; i >= 0; i --){
        ans = (ans + (a[i]-1)*bef[p[i]]) % MOD;
        for(int k = 0; k < i; k ++)
            cur[k] = (k*bef[k] + bef[k+1]) % MOD;
        for(int k = 0; k <= n; k ++)
            swap(bef[k], cur[k]);
    }
    cout << ans;
}
# 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
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 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 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
# 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 204 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 1 ms 204 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 204 KB Output is correct
2 Correct 2 ms 204 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 163 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 416 KB Output is correct
2 Correct 39 ms 332 KB Output is correct
3 Correct 42 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 179 ms 588 KB Output is correct
2 Correct 169 ms 588 KB Output is correct
3 Correct 156 ms 588 KB Output is correct