結果

問題 No.2374 ASKT Subsequences
ユーザー HIcoderHIcoder
提出日時 2023-07-24 12:23:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,696 bytes
コンパイル時間 1,086 ms
コンパイル使用メモリ 114,568 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-08 15:03:46
合計ジャッジ時間 8,483 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 2 ms
6,548 KB
testcase_04 AC 2 ms
6,548 KB
testcase_05 AC 2 ms
6,548 KB
testcase_06 AC 2 ms
6,548 KB
testcase_07 AC 5 ms
6,548 KB
testcase_08 AC 3 ms
6,548 KB
testcase_09 AC 4 ms
6,548 KB
testcase_10 AC 21 ms
6,548 KB
testcase_11 AC 57 ms
6,548 KB
testcase_12 AC 25 ms
6,548 KB
testcase_13 AC 19 ms
6,548 KB
testcase_14 AC 104 ms
6,548 KB
testcase_15 AC 166 ms
6,548 KB
testcase_16 AC 73 ms
6,548 KB
testcase_17 AC 525 ms
6,548 KB
testcase_18 AC 1,184 ms
6,548 KB
testcase_19 AC 1,016 ms
6,548 KB
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<queue>
#include<cmath>
#include<random>
#include<bitset>
//#include<fstream>

using namespace std;
typedef long long ll;
const ll INF=1LL<<60;
typedef pair<ll,ll> P;
typedef pair<int,P> PP;
const ll MOD=998244353;


int main(){
    int N;
    cin>>N;
    vector<ll> A(N);
    ll maxA=-INF;
    ll minA=INF;
    for(int i=0;i<N;i++){
        cin>>A[i];
        maxA=max(maxA,A[i]);
        minA=min(minA,A[i]);    
    }


    ll ans=0;


    for(ll k=1;k<=maxA-minA;k++){
        /*
        dp[i][j]=j番目の要素がA[i]となる
        */
        vector<vector<ll>> dp(N+1,vector<ll>(4,0));
        for(int i=0;i<N;i++){
            dp[i][0]=1;
        }
        
        for(int i=0;i<N;i++){
            for(int j=1;j<4;j++){
                if(j-1==0){
                    for(int x=0;x<i;x++){
                        if(A[i]==A[x]+(k+10)){
                            dp[i][j]+=dp[x][j-1];
                        }
                    }
                }else if(j-1==1){

                    for(int x=0;x<i;x++){
                        if(A[i]==A[x]-k){
                            dp[i][j]+=dp[x][j-1];
                        }
                    }


                }else if(j-1==2){

                    for(int x=0;x<i;x++){
                        if(A[i]==A[x]+(k+1)){
                            dp[i][j]+=dp[x][j-1];
                        }
                    }

                }


            }
        }

        for(int i=0;i<N;i++){
            
            ans+=dp[i][3];
    
        }


    }


    cout<<ans<<endl;



}
0