Submission #781100

# Submission time Handle Problem Language Result Execution time Memory
781100 2023-07-12T17:54:05 Z Charizard2021 Calvinball championship (CEOI15_teams) C++17
70 / 100
71 ms 476 KB
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000007;
int main(){
    int n;
    cin >> n;
    int dp[2][1 + n];
    int cur = n % 2;
    int a[1 + n];
    int prefMax[1 + n];
    prefMax[0] = 0;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        prefMax[i] = max(prefMax[i - 1], a[i]);
        dp[cur][i] = 1;
    }
    int ans = 1;
    for(int i = n - 1; i > 0; i--, cur ^= 1){
        ans = (ans + dp[cur][prefMax[i]] * (a[i + 1] - 1)) % MOD;
        for(int j = 1; j <= i; j++){
            dp[!cur][j] = (dp[cur][j] * j + dp[cur][j + 1]) % MOD;
        }
    }
    cout << ans << "\n";
}
# 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 300 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 300 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 0 ms 300 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
# 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 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 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 Incorrect 68 ms 472 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 71 ms 476 KB Output isn't correct
2 Halted 0 ms 0 KB -