結果
| 問題 | No.2374 ASKT Subsequences | 
| コンテスト | |
| ユーザー |  poyon | 
| 提出日時 | 2023-06-16 18:53:25 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 24 ms / 2,000 ms | 
| コード長 | 1,019 bytes | 
| コンパイル時間 | 2,040 ms | 
| コンパイル使用メモリ | 200,192 KB | 
| 最終ジャッジ日時 | 2025-02-14 03:50:59 | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 28 | 
ソースコード
#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;
}
            
            
            
        