結果

問題 No.2374 ASKT Subsequences
ユーザー poyonpoyon
提出日時 2023-06-16 18:53:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 1,019 bytes
コンパイル時間 2,231 ms
コンパイル使用メモリ 204,096 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-12 09:54:06
合計ジャッジ時間 3,392 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 3 ms
4,384 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 5 ms
4,380 KB
testcase_18 AC 6 ms
4,380 KB
testcase_19 AC 6 ms
4,380 KB
testcase_20 AC 17 ms
4,376 KB
testcase_21 AC 19 ms
4,380 KB
testcase_22 AC 15 ms
4,384 KB
testcase_23 AC 6 ms
4,376 KB
testcase_24 AC 6 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 23 ms
4,380 KB
testcase_27 AC 22 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 19 ms
4,376 KB
testcase_30 AC 5 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) { cin >> A[i]; }

    ll ans = 0;
    int MAX_A = *max_element(A.begin(), A.end());
    for (int k = 1; k <= MAX_A; k++) {
        // dp[j][x] := (A[0] 〜 A[i-1] まで見て、) x = a1 であって、
        //             あさかつ型の部分列の j 番目まで決めた場合の数
        vector<vector<ll>> dp(4, vector<ll>(MAX_A + 1));
        for (int a : A) {
            int x = a - k - 11;
            if (1 <= x) { dp[3][x] += dp[2][x]; }

            int y = a - 10;
            if (1 <= y) { dp[2][y] += dp[1][y]; }

            int z = a - k - 10;
            if (1 <= z) { dp[1][z] += dp[0][z]; }

            dp[0][a]++;
        }
        ans += accumulate(dp[3].begin(), dp[3].end(), 0ll);
    }
    cout << ans << '\n';

    return 0;
}
0