Submission #503350

# Submission time Handle Problem Language Result Execution time Memory
503350 2022-01-07T17:15:28 Z CraniXort Calvinball championship (CEOI15_teams) C++17
20 / 100
102 ms 576 KB
#include <bits/stdc++.h>

 #define fin std::cin
 #define fout std::cout

//std::ifstream fin("calvinball.in");
//std::ofstream fout("calvinball.out");


const long long mod = 1000000007;


int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    int n;
    fin >> n;
    std::vector <int> v(n), max(n);

    for(int i = 0; i < n; i ++)
        fin >> v[i];

    max[0] = 0;
    for(int i = 1; i < n; i ++)
        max[i] = std::max(max[i-1], v[i-1]);

    long long dp[2][n+1], current = 0, next = 1;
    for(int i = 0; i < n; i ++)
        dp[current][i] = 1;

    long long ans = 0;

    for(int i = n-1; i >= 0; i--, current ^= 1, next ^= 1) {
        ans = ans + (v[i] - 1) * dp[current][max[i]];
        ans %= mod;

        for(int j = 0; j < i; j ++)
            dp[next][j] = (j * dp[current][j] + dp[current][j+1]) % mod;
        
    }

    fout << (1 + ans) % mod << '\n';



    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 316 KB Output is correct
4 Correct 0 ms 312 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 312 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 312 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 296 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 216 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 98 ms 576 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 324 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 102 ms 560 KB Output isn't correct
2 Halted 0 ms 0 KB -