結果
問題 |
No.1470 Mex Sum
|
ユーザー |
|
提出日時 | 2024-12-21 16:16:30 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 571 bytes |
コンパイル時間 | 911 ms |
コンパイル使用メモリ | 93,920 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-21 16:16:33 |
合計ジャッジ時間 | 3,385 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 14 WA * 35 |
ソースコード
#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>(count_2) * 2 << '\n'; return 0; }