結果
問題 |
No.1470 Mex Sum
|
ユーザー |
|
提出日時 | 2024-12-21 16:20:44 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 17 ms / 2,000 ms |
コード長 | 613 bytes |
コンパイル時間 | 826 ms |
コンパイル使用メモリ | 94,160 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-21 16:20:48 |
合計ジャッジ時間 | 2,886 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 49 |
ソースコード
#include <iostream> #include <cstdint> #include <vector> #include <algorithm> using namespace std; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int32_t N, i; cin >> N; vector<int32_t> A(N); for (i = 0; i != N; ++i) cin >> A[i]; int32_t count_1 = 0, count_2 = 0; for (i = 0; i != N; ++i) switch (A[i]) { case 1: ++count_1; break; case 2: ++count_2; break; } cout << N * static_cast<int64_t>(N - 1) / 2 + count_1 * static_cast<int64_t>(count_1 - 1) / 2 + count_1 * static_cast<int64_t>(N - count_1) + count_1 * static_cast<int64_t>(count_2) << '\n'; return 0; }