結果

問題 No.2374 ASKT Subsequences
ユーザー karinohitokarinohito
提出日時 2023-07-07 22:05:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 709 bytes
コンパイル時間 2,127 ms
コンパイル使用メモリ 202,244 KB
実行使用メモリ 35,016 KB
最終ジャッジ日時 2023-09-28 23:23:17
合計ジャッジ時間 3,867 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 4 ms
4,916 KB
testcase_11 AC 6 ms
7,744 KB
testcase_12 AC 4 ms
5,980 KB
testcase_13 AC 4 ms
5,576 KB
testcase_14 AC 8 ms
9,512 KB
testcase_15 AC 9 ms
11,332 KB
testcase_16 AC 6 ms
8,360 KB
testcase_17 AC 12 ms
13,364 KB
testcase_18 AC 19 ms
18,832 KB
testcase_19 AC 17 ms
17,600 KB
testcase_20 AC 27 ms
24,280 KB
testcase_21 AC 31 ms
27,176 KB
testcase_22 AC 23 ms
22,148 KB
testcase_23 AC 19 ms
18,996 KB
testcase_24 AC 19 ms
19,152 KB
testcase_25 AC 17 ms
19,048 KB
testcase_26 AC 45 ms
34,660 KB
testcase_27 AC 33 ms
34,920 KB
testcase_28 AC 38 ms
34,692 KB
testcase_29 AC 33 ms
34,796 KB
testcase_30 AC 37 ms
35,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vll =vector<ll>;
using vvll =vector<vll>;
#define rep(i,n) for(ll i=(ll)(0); i<(ll(n)); ++i)
#define all(x) (x).begin(), (x).end()

int main(){
    ll N;
    cin>>N;
    vvll A(2001,vll(N+1));
    vll B(N);
    rep(i,N){
        cin>>B[i];
        A[B[i]][i+1]++;
    }
    rep(i,2001){
        rep(j,N)A[i][j+1]+=A[i][j];
    }

    ll an=0;
    rep(i,N)rep(j,i){
        ll a2=B[j];
        ll a3=B[i];
        ll k=a2-a3;
        if(k<=0)continue;
        ll a1=a2-k-10;
        ll a4=a3+k+1;
        if(a1<=0||a4>=2001)continue;
        ll n1=A[a1][j];
        ll n4=A[a4][N]-A[a4][i];
        an+=n1*n4;
    }
    cout<<an<<endl;
}
0