結果

問題 No.2374 ASKT Subsequences
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-07-07 22:37:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 707 bytes
コンパイル時間 2,392 ms
コンパイル使用メモリ 203,212 KB
実行使用メモリ 34,584 KB
最終ジャッジ日時 2023-09-29 00:08:37
合計ジャッジ時間 3,782 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 3 ms
4,752 KB
testcase_11 AC 6 ms
7,260 KB
testcase_12 AC 4 ms
5,752 KB
testcase_13 AC 4 ms
5,148 KB
testcase_14 AC 9 ms
9,212 KB
testcase_15 AC 10 ms
11,224 KB
testcase_16 AC 7 ms
8,048 KB
testcase_17 AC 13 ms
13,020 KB
testcase_18 AC 21 ms
18,876 KB
testcase_19 AC 19 ms
17,296 KB
testcase_20 AC 31 ms
24,212 KB
testcase_21 AC 35 ms
26,536 KB
testcase_22 AC 26 ms
21,780 KB
testcase_23 AC 21 ms
18,824 KB
testcase_24 AC 20 ms
18,828 KB
testcase_25 AC 19 ms
18,836 KB
testcase_26 AC 51 ms
34,404 KB
testcase_27 AC 36 ms
34,520 KB
testcase_28 AC 43 ms
34,576 KB
testcase_29 AC 37 ms
34,460 KB
testcase_30 AC 38 ms
34,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main(){

    ll N, ans=0;
    cin >> N;
    vector<int> A(N+1);

    vector<vector<int>> S(N+1, vector<int>(2001)), T(N+2, vector<int>(2001));

    for (int i=1; i<=N; i++){
        cin >> A[i];
        S[i][A[i]]++;
        T[i][A[i]]++;
    }

    for (int i=1; i<=N; i++) for (int j=0; j<=2000; j++) S[i][j] += S[i-1][j];
    for (int i=N; i>=1; i--) for (int j=0; j<=2000; j++) T[i][j] += T[i+1][j];

    for (int i=1; i<=N; i++){
        for (int j=i+1; j<=N; j++){
            if (A[j]-10>=0 && A[i]+1<=2000 && A[i]-A[j] >= 1) ans += S[i-1][A[j]-10] * T[j+1][A[i]+1];
        }
    }

    cout << ans << endl;

    return 0;
}
0