結果
問題 |
No.1470 Mex Sum
|
ユーザー |
![]() |
提出日時 | 2021-01-07 18:48:39 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 43 ms / 2,000 ms |
コード長 | 451 bytes |
コンパイル時間 | 1,942 ms |
コンパイル使用メモリ | 167,792 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-09 01:19:11 |
合計ジャッジ時間 | 5,757 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 49 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #define fi first #define se second int main(){ int n; cin>>n; ll a[n]; ll count[4]={}; for(int i=0;i<n;i++){ cin>>a[i]; if(a[i]<1||a[i]>1e9){ cout<<i<<" : "<<"WARNING"<<endl; } if(a[i]>3){ a[i]=3; } count[a[i]]++; } ll x=count[1],y=count[2],z=count[3]; ll ans=(y*(y-1))/2+y*z+(z*(z-1))/2+x*(x-1)+2*x*z+3*x*y; cout<<ans<<endl; }