結果
問題 | No.118 門松列(2) |
ユーザー |
|
提出日時 | 2020-07-22 05:02:09 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 9 ms / 5,000 ms |
コード長 | 545 bytes |
コンパイル時間 | 2,031 ms |
コンパイル使用メモリ | 193,168 KB |
最終ジャッジ日時 | 2025-01-12 01:54:29 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) const long long MOD = 1e9 + 7; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long n; cin >> n; long long ret = n * (n-1) * (n-2) / 6; vector<int> hist(101); REP (i, n) { int a; cin >> a; hist[a]++; } REP (i, 101) { long long h = hist[i]; if (h >= 2) ret -= h * (h-1) / 2 * (n - h); if (h >= 3) ret -= h * (h-1) * (h-2) / 6; } cout << ret % MOD << endl; return 0; }