結果
問題 | No.1470 Mex Sum |
ユーザー |
![]() |
提出日時 | 2021-04-09 21:23:23 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 49 ms / 2,000 ms |
コード長 | 545 bytes |
コンパイル時間 | 3,996 ms |
コンパイル使用メモリ | 249,612 KB |
最終ジャッジ日時 | 2025-01-20 13:25:35 |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 49 |
ソースコード
#include <stdio.h> #include <atcoder/all> #include <bits/stdc++.h> using namespace std; using namespace atcoder; using mint = modint998244353; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000000000000 int main(){ int N; cin>>N; vector<long long> t(3,0LL); rep(i,N){ int A; cin>>A; A--; t[min(2,A)]++; } long long ans = 0LL; ans += t[0]*(t[0]-1)/2 * 2; ans += t[0]*t[1] * 3; ans += t[0]*t[2] * 2; ans += t[1]*(t[1]-1)/2; ans += t[1]*t[2]; ans += t[2]*(t[2]-1)/2; cout<<ans<<endl; return 0; }