結果
| 問題 |
No.1470 Mex Sum
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-04-14 22:14:52 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,213 bytes |
| コンパイル時間 | 990 ms |
| コンパイル使用メモリ | 93,732 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-30 21:02:12 |
| 合計ジャッジ時間 | 3,636 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 10 WA * 39 |
ソースコード
//#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() {
int 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;
}