結果

問題 No.118 門松列(2)
ユーザー youjo_yamiotiyoujo_yamioti
提出日時 2018-12-09 04:46:40
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 850 bytes
コンパイル時間 1,244 ms
コンパイル使用メモリ 154,952 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-14 10:33:00
合計ジャッジ時間 2,552 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int memo[100000] = {0};
int sum(int N,vector<int> vec){
    if(N == 1) return memo[1] = vec[1];
    else{
        if(memo[N] != 0) return memo[N];
        return memo[N] = vec[N] + sum(N-1,vec);
    }
}
long int T(int N,vector<int> vec){
    if(N == 2) return vec[1] * vec[2];
    else{
        return T(N-1,vec) + sum(N-1,vec) * vec[N];    
    }
}

long int S(int N,vector<int> vec){
    if(N == 3) return vec[1] * vec[2] * vec[3];
    else return (S(N-1,vec) + T(N-1,vec) * vec[N]) % 1000000007;
}

int main(){
    int N;
    cin >> N;
    vector<int> L(N,0);
    map<int,int> m;
    for(int i=0;i<N;i++){
        cin >> L[i];
        m[L[i]]++;
    } 
    vector<int> vec = {};
    for(auto i : m){
        vec.push_back(i.second);
    }

    cout << S(vec.size(),vec) << endl;

    return 0;

    
}
0