結果

問題 No.118 門松列(2)
ユーザー なお
提出日時 2015-01-06 23:34:45
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 20 ms / 5,000 ms
コード長 405 bytes
コンパイル時間 2,618 ms
コンパイル使用メモリ 159,436 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-09 06:49:46
合計ジャッジ時間 2,273 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n)           for(int(i)=0;(i)<(n);++(i))
const int MOD = 1e9+7;
ll A[111111],B[111];
int main(){
    int N; cin>>N;
    REP(i,N){cin >> A[i]; B[A[i]]++;}
    for(int i = 1; i <= 100; i++) B[i] = B[i] + B[i-1];
    ll res = 0;
    REP(i,N){int v = A[i]; res += (B[v-1]*(B[100]-B[v])) % MOD;}
    cout << res%MOD << endl;
}
0