結果
問題 |
No.1470 Mex Sum
|
ユーザー |
|
提出日時 | 2021-04-09 21:39:09 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 20 ms / 2,000 ms |
コード長 | 658 bytes |
コンパイル時間 | 636 ms |
コンパイル使用メモリ | 72,868 KB |
最終ジャッジ日時 | 2025-01-20 13:51:32 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 49 |
ソースコード
#line 1 "main.cpp" #include <iostream> #include <algorithm> #include <numeric> #include <vector> #include <string> using namespace std; using lint = long long; void solve() { lint n; cin >> n; lint ones = 0, twos = 0; for (int i = n; i--;) { int x; cin >> x; if (x == 1) { ++ones; } else if (x == 2) { ++twos; } } lint three = ones * twos; lint one = (n - ones) * (n - ones - 1) / 2; cout << one + (n * (n - 1) / 2 - one - three) * 2 + three * 3 << "\n"; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); solve(); return 0; }