結果
| 問題 |
No.118 門松列(2)
|
| ユーザー |
|
| 提出日時 | 2015-05-11 16:23:36 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 19 ms / 5,000 ms |
| コード長 | 543 bytes |
| コンパイル時間 | 773 ms |
| コンパイル使用メモリ | 61,020 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-09 06:59:02 |
| 合計ジャッジ時間 | 1,544 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 26 |
ソースコード
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
const int mod = 1e9 + 7;
int main() {
int n, a;
cin >> n;
vector<int> num(101, 0);
for (int i = 0; i < n; i++) {
cin >> a;
num[a]++;
}
int lower = 0;
int mid = 0;
int higher = n;
long long ans = 0;
for (int i = 0; i < num.size(); i++) {
if (num[i] > 0) {
lower += mid;
mid = num[i];
higher -= num[i];
ans += 1LL * lower * mid * higher;
}
}
ans %= mod;
cout << ans << endl;
return 0;
}