結果

問題 No.2374 ASKT Subsequences
ユーザー ぷら
提出日時 2023-07-07 22:31:02
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 613 bytes
コンパイル時間 1,950 ms
コンパイル使用メモリ 194,316 KB
最終ジャッジ日時 2025-02-15 07:51:02
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int>A(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    vector<int>B(2020);
    long long ans = 0;
    for(int i = 0; i < N; i++) {
        vector<int>C(2020);
        for(int j = N-1; j > i; j--) {
            int k = A[i]-A[j];
            if(A[i]-10-k >= 0 && A[j]+k+1 <= 2000 && k >= 1) {
                ans += 1ll*B[A[i]-10-k]*C[A[j]+k+1];
            }
            C[A[j]]++;
        }
        B[A[i]]++;
    }
    cout << ans << endl;
}
0