結果
問題 | No.1470 Mex Sum |
ユーザー |
|
提出日時 | 2021-04-09 23:31:36 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 46 ms / 2,000 ms |
コード長 | 449 bytes |
コンパイル時間 | 1,962 ms |
コンパイル使用メモリ | 191,992 KB |
最終ジャッジ日時 | 2025-01-20 15:17:40 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 49 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; int n; ll cnt[3]; int main() { cin >> n; for (int i = 0; i < n; ++i) { int A; cin >> A; if (A > 3) A = 3; ++cnt[A - 1]; } ll ans = 0; ans += cnt[1] * (cnt[1] - 1) / 2 + cnt[2] * (cnt[2] - 1) / 2 + cnt[1] * cnt[2]; ans += cnt[0] * (cnt[0] - 1) + 2 * cnt[0] * cnt[2]; ans += 3 * cnt[0] * cnt[1]; cout << ans << '\n'; return 0; }