結果

問題 No.2374 ASKT Subsequences
ユーザー nouka28nouka28
提出日時 2023-07-07 22:34:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 1,131 bytes
コンパイル時間 5,374 ms
コンパイル使用メモリ 264,224 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-29 00:04:40
合計ジャッジ時間 6,255 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
#define int long long
#define intu __int128_t
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define reps(i,a,b,c) for(int i=a;i<b;i+=c)
#define repnega(i,a,b) for(int i=b;i>a;i--)
#define mod2 1000000007
#define mod 998244353
#define endl '\n'
#define AC ios_base::sync_with_stdio(false);cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ceil(a,b) (a+b-1)/b
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")

int n;
signed main(){
    cin>>n;
    vector<int> a(n);
    set<int> st;
    rep(i,n)cin>>a[i];
    rep(i,n)st.insert(a[i]);
    int ans=0;
    rep1(k,2000){
        int cnt[2009][4];
        rep(i,2001)rep(j,4)cnt[i][j]=0;
        rep(i,n){
            cnt[a[i]][0]++;
            if(a[i]-k-10>0)cnt[a[i]][1]+=cnt[a[i]-k-10][0];
            if(a[i]+k<2005)cnt[a[i]][2]+=cnt[a[i]+k][1];
            if(a[i]-k-1>0)cnt[a[i]][3]+=cnt[a[i]-k-1][2];
        }
        rep1(i,2000)ans+=cnt[i][3];
        
    }
    cout<<ans<<endl;
    
}
0