Submission #100674

# Submission time Handle Problem Language Result Execution time Memory
100674 2019-03-13T06:51:39 Z win11905 Calvinball championship (CEOI15_teams) C++11
100 / 100
97 ms 536 KB
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author win11905
 */

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define iii tuple<int, int, int>
#define long long long
#define pii pair<int, int>
#define x first
#define y second
using namespace std;
const long MOD = 1e6+7, LINF = 1e18 + 1e16;
const int INF = 1e9+1;
const double EPS = 1e-10;
const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};

const int N = 1e4+5;

class calvinball {
private:
    int n;
    int inp[N];
    int dp[N];
public:
    void solve(istream& cin, ostream& cout) {
        cin >> n;
        for(int i = 1; i <= n; ++i) cin >> inp[i];
        int mx = 0;
        for(int i = 1; i <= n; ++i) {
            for(int j = i; j; --j) dp[j] = (dp[j-1] + 1ll * dp[j] * j) % MOD;
            dp[mx] += inp[i]-1;
            mx = max(mx, inp[i]);
        }
        int sum = 1;
        for(int i = 1; i <= n; ++i) sum = (sum + dp[i]) % MOD;

        cout << sum << endl;
    }
};

class Solver {
public:
    void solve(std::istream& in, std::ostream& out) {
        calvinball *obj = new calvinball();
        obj->solve(in, out);
    }
};

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    Solver solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 89 ms 476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 384 KB Output is correct
2 Correct 24 ms 512 KB Output is correct
3 Correct 24 ms 516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 88 ms 460 KB Output is correct
2 Correct 91 ms 512 KB Output is correct
3 Correct 97 ms 536 KB Output is correct