結果
問題 |
No.118 門松列(2)
|
ユーザー |
![]() |
提出日時 | 2015-01-06 23:26:53 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,015 bytes |
コンパイル時間 | 1,237 ms |
コンパイル使用メモリ | 93,428 KB |
実行使用メモリ | 10,780 KB |
最終ジャッジ日時 | 2024-06-13 02:46:23 |
合計ジャッジ時間 | 7,699 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 1 TLE * 1 -- * 24 |
ソースコード
#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; }