답안 #138968

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
138968 2019-07-31T04:51:58 Z meatrow Calvinball championship (CEOI15_teams) C++17
100 / 100
636 ms 888 KB
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

const int N = 1e4 + 5;
ll mod = 1e6 + 7;

ll dp[2][N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int level = 1;
    for (int i = 1; i < n; i++) {
        int q = i & 1;
        for (int j = 1; j <= i + 1; j++) {
            dp[q][j] = (dp[q ^ 1][j - 1] + dp[q ^ 1][j] * j) % mod;
        }
        (dp[q][level] += a[i] - 1) %= mod;
        level = max(level, a[i]);
    }
    int ans = 1;
    for (int i = 1; i <= n; i++) {
        (ans += dp[(n - 1) & 1][i]) %= mod;
    }
    cout << ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 296 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 376 KB Output is correct
2 Correct 8 ms 376 KB Output is correct
3 Correct 8 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 604 ms 744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 155 ms 580 KB Output is correct
2 Correct 155 ms 504 KB Output is correct
3 Correct 156 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 614 ms 888 KB Output is correct
2 Correct 618 ms 732 KB Output is correct
3 Correct 636 ms 784 KB Output is correct