結果

問題 No.118 門松列(2)
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2015-01-06 23:26:53
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,015 bytes
コンパイル時間 1,749 ms
コンパイル使用メモリ 90,460 KB
実行使用メモリ 7,956 KB
最終ジャッジ日時 2023-09-03 22:07:37
合計ジャッジ時間 8,495 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))

#define MOD 1000000007

int main(){
  int n;
  cin>>n;
  vector<int> v;
  rep(i,0,n){
    int a;
    cin>>a;
    v.pb(a);
  }
  sort(all(v));
  long long ans = 0LL;
  rep(i,0,v.sz){
    int a = 0;
    int b = 0;
    rep(j,0,i){
      if(v[j]<v[i]){
        a++;
      }
    }
    rep(j,i+1,v.sz){
      if(v[j]>v[i]){
        b++;
      }
    }
    ans += a*b;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}

0