結果
問題 |
No.1470 Mex Sum
|
ユーザー |
|
提出日時 | 2021-04-14 22:16:08 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 17 ms / 2,000 ms |
コード長 | 1,218 bytes |
コンパイル時間 | 1,102 ms |
コンパイル使用メモリ | 93,356 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-30 21:03:29 |
合計ジャッジ時間 | 3,360 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 49 |
ソースコード
//#include <atcoder/all> #include <bitset> #include <fstream> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; //using namespace atcoder; //* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *// void input() { } void solve() { long long N; cin >> N; long long A1 = 0, A2 = 0, A3 = 0; for(int i = 0; i < N; i++) { int A; cin >> A; if(A == 1) A1++; else if(A == 2) A2++; else A3++; } long long ans = 0; long long tmp = 0; tmp += A1 * A2 * 2; tmp += A1 * A1; tmp += A1 * A3 * 2; ans += A1 * A2 * 2 * 3; ans += A1 * A1 * 2; ans += A1 * A3 * 2 * 2; ans += (N * N - tmp) * 1; ans -= A1 * 2; ans -= (N - A1) * 1; ans /= 2; cout << ans << endl; } //* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *// int main() { std::ifstream in("input.txt"); std::cin.rdbuf(in.rdbuf()); std::cin.tie(0); ios::sync_with_stdio(false); input(); solve(); return 0; }