답안 #100678

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
100678 2019-03-13T07:22:14 Z szawinis Calvinball championship (CEOI15_teams) C++17
100 / 100
103 ms 632 KB
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <bits/stdc++.h>
using namespace std;
#define long long long
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 = 10001;

class Calvinball {
    int n, a[N], mx[N];
    long dp[N];
public:
    void solve(istream &cin, ostream &cout) {
        cin >> n;
        for(int i = 1; i <= n; i++) {
            cin >> a[i];
            mx[i] = max(mx[i-1], a[i]);
        }
        for(int i = 1; i <= n; i++) {
            for(int j = i; j >= 1; j--) {
                dp[j] = (dp[j - 1] + 1ll * j * dp[j]) % MOD;
            }
            dp[mx[i-1]] += a[i] - 1;
        }
        long ans = 1;
        for(int i = 1; i <= n; i++) {
            ans = (ans + dp[i]) % MOD;
        }
        cout << ans << endl;
    }
};

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

int 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 1 ms 484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 512 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 3 ms 512 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 512 KB Output is correct
2 Correct 3 ms 512 KB Output is correct
3 Correct 3 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 512 KB Output is correct
2 Correct 4 ms 508 KB Output is correct
3 Correct 3 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 89 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 512 KB Output is correct
2 Correct 25 ms 512 KB Output is correct
3 Correct 26 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 103 ms 512 KB Output is correct
2 Correct 96 ms 512 KB Output is correct
3 Correct 103 ms 632 KB Output is correct